Copyright: DTime v1.11 (C) PJ Naughter 1996


A Collection of Date and Time Classes for Win32, Win32s, Win16 & Dos

Version 1.11

Copyright (c) 1996 by PJ Naughter

DTime is a collection of classes & functions designed to ease the MFC programmers burden when handling date and time values. The package is provided at no charge to users for evaluation. Feel free to share it with your friends and colleagues. The essence of user-supported software is to provide computer users with quality software without high prices, and at the same time to provide incentive for programmers to continue to develop new products.

Class Features	CDate Index

Acknowledgements	CLTimeSpan Index

Contacting the Author	CLTimeOfDay Index

Structures used by the classes	CLDate Index

Demo Programs	Data Entry

Push Pin Button	File Shipping List

Global Functions	Settings Applet

Registration	How to Use

Future Enhancements	Revision History

CStringEx	Uninstalling

German Version

Note:

This help file can also be used for extension help inside the IDE of Developer Studio. For further information about this new feature of VC, Search for “Using Your Own Help Files” (Title only) in Visual C++ Books Online.


Class Features

If like me, having taken a look at the built in MFC classes CTime and CTimeSpan or the new COleDateTime and COleDateTimeSpan you decided they did not meet your requirements and you wanted to write your own super-duper date and time classes, but deadlines were looming, then look no further.

Some of the many features Include:

All source code is supplied for debugging / inspection.

The code is fully portable between the following platforms: Dos, Win16, Win32s, Win32 (Windows 95), Win32 (NT) and Win32 (NT Unicode).

The classes sticks very closely to the MFC class structures and provides routines to map from CTime, COleDateTime, COleDateTimeSpan and CTimeSpan. Mappings are also available to convert to and from Win32 SDK date and time structures.

The classes do not rely on the "C" runtime library like CTime does. If you have used the CTime class then you will no doubt have come across its dependence on the environment variable "TZ" and all the problems that can give. The classes use of UCT / Local is much less vague than CTime which performs automatic mappings which can confuse even the most experienced developer.

A number of date / time classes are provided namely CDate, CLTimeSpan, CLTimeOfDay and CLDate.

A comprehensive set of classes and DDX and DDV routines which make use of the new spin controls and new "Windows 95" look and feel are also provided to connect to the user interface.

An applet program is provided to allow the commonly used values of the classes to be modified in a central location. These values are modifiable per user.

Format functions with a superset of the functionality provided by CTime/CTimeSpan::Format. The routine is available in the DLL format of MFC unlike the CTime version.

CDate provides a granularity of 1 day and uses a LONG to represent the count of days and as such the class is exactly 4 bytes LONG. Its range is valid for roughly the whole range of a LONG i.e. +/- 2 billion days from the current era.

CLTimeOfDay provides a granularity of 1 millisecond and uses 6 bytes.

CLTimeSpan provides a granularity of 1 millisecond and uses a 10 byte double.

CLDate provides a granularity of 1 millisecond and uses a 10 byte double. As with CDate, the full range of a LONG is valid. This is "quite" larger than the roughly 60 year time span for CTimeSpan and the 100 CE - 9999CE time span for COleDateTime.

All classes are fully Unicode enabled and can be built for NT Unicode.

All classes are fully enabled for translation by storing all strings as resources (partly available even on Dos).

Classes fully support UCT (GMT), Local and ET (Ephemeris Time) time frames and includes functions to map between them.

Classes also fully support the two most common calendars in use, namely the GREGORIAN and JULIAN calendars.

A push pin button class (similar to X-Windows, MSDEV) is used internally and is available for external use.

A comprehensive OS detection routine is available. It can detect between the following OS's:Dos, Windows 3.0, Windows 3.1, Windows for Workgroups, Windows 95, NT, NT Server  and NT Advanced Server. This function is available on all platforms and can return such information as "You Are running Dos v7.00 on Windows 95".

A CStringEx class is available when compiled for Win16 or Dos. It includes a Format routine similar to the built in CString::Format routine which is only available on Win32

A "printf" like routine is also available when compiled under Win16 which allows you to output diagnostics etc at runtime.

Demonstation of features such as message reflection, use of CToolTipCtrl, spin buttons, number only edit boxes, console functions in Win32 MFC apps, accessing the registry, accessing environment variables from Win16 DLL's, OS Version detection, Generic Thunking, Unicode, dragging whole Windows, DDX & DDV routines, MFC Extensions DLL's, portable code techniques plus many other features often asked about.


Acknowledgements

The basis of the algorithms for conversion from the Julian and Gregorian Calendar to the underlying storage were taken from an article in the magazine “Microsoft Systems Journal”. The algorithm used to determine the date of Easter Sunday and DeltaT are taken from the book “Astronomical Algorithms” by Jean Meeus.


The Author

PJ Naughter,

Snail Mail:

Cahore,

Ballygarrett,

Gorey,

Co. Wexford,

Ireland,

Tel No:

+353-1-2958384 (Work)

+353-55-27392 (Weekends only)

Email:

Internet: 	pjn@indigo.ie

Compuserve:	100444,1550

I would be grateful if you find the classes useful or you have any suggestions, comments or bug reports then feel free to send me an email or postcard.


Global Functions

InitDTime

Initialises the DTime package

TermDTime

Closes use of  the DTime package

GetDTimeVersion

Returns the version of the DTime package.

InitDTimeSettings

Initialises the static members of the 4 DTime classes from the registry/environment as set up by the Settings Applet

GetOSVersion

Returns the emulated and underlying Operating System the program is currently running under.

GetTimeZoneInformation

An Implementation of the Win32 function of the same name when on Win16 & Dos.

Win16Printf

Allows a Win16 application to use a function similar to the “C” runtime function “printf”.


CDate Index

Construction

CDate

Constructs CDate objects in various ways.

Setting

Set

Allows you to set the value after its constructor has been called.

Static Constructors

CurrentDate

Creates a CDate object that represents the current time.

FirstCurrentMonth

Returns a CDate object that represents the 1st of the current month.

LastCurrentMonth

Returns a CDate object that represents the last day of the current month.

FirstCurrentYear

Returns a CDate object that represents the 1st of January for the current year.

LastCurrentYear

Returns a CDate object that represents the 31st of December for the current year.

JDEpoch

Returns a CDate object that represents the 1st of January -4712.

MJDEpoch

Returns a CDate object that represents the Modified Julian Day i.e. JD - 24000000.

Epoch1900

Returns a CDate object that represents the1st of January 1900.

Epoch1950

Returns a CDate object that represents the 1st of January 1950.

EpochCTime

Returns a CDate object that represents the 1st of January 1970.

Epoch2000

Returns a CDate object that represents the 1st of January 2000.

GregorianEpoch

Returns a CDate object that represents the Gregorian Epoch.

Static Operations

IsLeap

Returns whether a year is leap.

DaysInYear

Returns the number of Days in a Year.

DaysInMonth

Returns the Number of Days in a Month.

DaysSinceJan1

Returns the Number of Days in a year since 1st January.

DaysSinceJan0

Returns the Number of Days in a year since 31st December of the previous year.

SetDefaultFormat

Sets the default display format.

GetDefaultFormat

Retrieves the default display format.

CurrentMonth

Returns the current month (1 through 12).

CurrentDay

Returns the current Day (1 through 31).

CurrentYear

Returns the current Year.

CurrentDayOfWeek

Returns the current day of the week (1 for Sunday, 2 for Monday, and so forth).

SetBeginingDayOfWeek

Sets the day of week which marks a new week.

GetBeginingDayOfWeek

Returns the beginning day of week.

SetEndJulianCalendar

Set the date when the Julian Calendar ceased.

SetBeginGregCalendar

Set the date when the Gregorian Calendar  began.

GetEndJulianCalendar

Returns the date when the Julian Calendar ceased.

GetBeginGregCalendar

Returns the date when the Gregorian Calendar began.

InGregorianCalendar

Determines if a date is in the Gregorian Calendar.

SetDoConstructorAsserts

Sets whether or not ASSERTS are used.

GetFullStringDayOfWeek

Returns the day of the week as a string (“Sunday“ for Sunday, ”Monday“ for Monday, and so forth).

GetAbrStringDayOfWeek

Returns the day of the week as a string (“Sun“ for Sunday, “Mon“ for Monday, and so forth).

GetFullStringMonth

Returns the month (“January“ for January, “February“ for February, and so forth).

GetAbrStringMonth

Returns the month (“Jan“ for January, “Feb“ for February, and so forth).

Static Holiday Constructors

NewYearsDay

Returns a CDate object that represents the 1st of January for the current year. (same as FirstCurrentYear)

ValentinesDay

Returns a CDate object that represents Valentines Day.

AshWednesday

Returns a CDate object that represents Ash Wednesday.

StPatricksDay

Returns a CDate object that represents St. Patrick’s Day.

GoodFriday

Returns a CDate object that represents Good Friday.

EasterSunday

Returns a CDate object that represents Easter Sunday.

CanadaDay

Returns a CDate object that represents Canada Day.

IndependenceDay

Returns a CDate object that represents Independence Day.

BastilleDay

Returns a CDate object that represents Bastille Day.

ChristmasDay

Returns a CDate object that represents Christmas Day.

Operations

DaysSinceJan1

Returns the Number of Days for this CDate since 1st January.

DaysSinceJan0

Returns the Number of Days for this CDate since 31st December of the previous year.

GetDate

Breaks down a CDate object into components.

GetDay

Returns the Day that this CDate object represents (1 through 31).

GetMonth

Returns the month that this CDate object represents (1 through 12).

GetYear

Returns the Year that this CDate object represents.

GetCEBCEYear

Returns the Year as a Current Epoch / Before Current Epoch Year.

Get2DigitYear

Returns the last two digits of the Year.

Since1900Epoch

Returns the number of days since 1st January 1900.

Since1950Epoch

Returns the number of days since 1st January 1950.

SinceCTimeEpoch

Returns the number of days since 1st January 1970.

Since2000Epoch

Returns the number of days since 1st January 2000.

GDN

Returns the number of days since the Gregorian Epoch.

JD

Returns the number of days since 1st January -4712.

IsLeap

Returns true if this CDate’s year is leap, false if not.

DaysInYear

Returns the number of Days in this CDate’s year.

DaysInMonth

Returns the number of Days in this CDate’s month.

AddYear

Adds a number of years to this CDate.

AddWeek

Adds a number of weeks to this CDate.

AddMonth

Adds a number of month to this CDate.

GetDayOfWeek

Returns the day of the week  (1 for Sunday, 2 for Monday, and so forth).

GetStringCEBCEYear

Returns the CE/BCE year as a string.

GetFullStringDayOfWeek

Returns the day of the week as a string (“Sunday“ for Sunday, ”Monday“ for Monday, and so forth).

GetAbrStringDayOfWeek

Returns the day of the week as a string (“Sun“ for Sunday, “Mon“ for Monday, and so forth).

GetFullStringMonth

Returns the month (“January“ for January, “February“ for February, and so forth).

GetAbrStringMonth

Returns the month (“Jan“ for January, “Feb“ for February, and so forth).

GetSYSTEMTIME

Returns a SYSTEMTIME representation.

GetTM

Returns a “C” runtime tm representation.

GetWeekOfYear

Returns the week of the year.

GetWeekOfMonth

Returns the week of the month.

IsValid

Returns true if this CDate is a valid date, false if not.

Collate

Provides a numeric output suitable for database storage and use.

InGregorianCalendar

returns whether this value is in the Gregorian Calendar

Creation of other CDate's from this instance

FirstThisMonth

Returns a CDate object that represents the 1st of the month for this CDate.

LastThisMonth

Returns a CDate object that represents the last of the month for this CDate.

FirstThisYear

Returns a CDate object that represents the 1st of January for this CDate.

LastThisYear

Returns a CDate object that represents the 31st of December for this CDate.

Overloaded Arithmetic Operators

operator=

Assigns new date values.

operator+,-

Add and subtract CDate objects.

operator+=, -=

Add and subtract a date span to and from this CDate object.

operator++

Adds one day to this CDate object.

operator--

Subtracts one day from this CDate object.

operator==, <, etc.

Compares two CDates.

Diagnostics / Debug

AssertValid

Validates this object's integrity

Dump

Produces a diagnostic dump of this object.

Display

Format

Converts a CDate object into a formatted string.

Streaming

Serialize

Loads or stores a CDate from/to a MFC archive.

operator<<

Outputs a CDate to a C++ io stream.

operator<<

Stores a CDate on a MFC CArchive.

operator>>

Loads a CDate from a MFC CArchive.


CDate Constructors

CDate::CDate();

CDate::CDate(LONG Year, WORD Month, WORD Day);

CDate::CDate(const SYSTEMTIME& st);

CDate::CDate(LONG Year, WORD Month, WORD WeekOfMonth, WORD DayOfWeek);

CDate::CDate(LONG Days, DateEpoch e);

CDate::CDate(const CDate& d);

CDate::CDate(const CTime& ct);

CDate::CDate(const COleDateTime& oleTime);

Parameters

Year, Month, Day: Indicates a year, month and day.

d:	Indicates a CDate object that already exists.

ct:	Indicates a CTime object that already exists.

WeekOfMonth: 	The week of the month (1 - 5).

DayOfWeek : 	The day of the week e.g. SUNDAY.

oleTime:	An OLE Date.

Note:

1) The default constructor creates an invalid CDate

2) if sm_bDoAsserts is set (via SetDoConstructorAsserts), the constructors will assert in debug mode if any of the parameters are invalid

3) if WeekOfMonth is 5 then it means the last week in the month. This is similar to the way the Win32 SDK operates.

4) Only the day, month and year values in the SYSTEMTIME structure and CTime class are used.

5) See the Structures used by the classes for the definition of the enums used to represent the day of week.

6) The constructor involving the OLE date is only available when on 32 bit Windows.


CDate Set functions

CDate& CDate::Set();

CDate& CDate::Set(LONG Year, WORD Month, WORD Day);

CDate& CDate::Set(const SYSTEMTIME& st);

CDate& CDate::Set(LONG Year, WORD Month, WORD WeekOfMonth, WORD DayOfWeek);

CDate& CDate::Set(LONG Days, DateEpoch e);

CDate& CDate::Set(const CDate& d);

CDate& CDate::Set(const CTime& ct);

CDate& CDate::Set(const COleDateTime& oleTime);

Return Value

A reference to this instance.

Parameters

See CDate Constructors

Note:

1) These functions are actually called by the constructors. They allow a CDate’s value to be modified even after construction.

2) The set function involving the OLE date is only available when on 32 bit Windows.


CDate::CurrentDate
static CDate::CurrentDate();

Returns a CDate which represents the current date as taken from the system clock. The date used is interpreted as a local time.


static WORD CDate::CurrentMonth();

Returns a WORD which represents the current month as taken from the system clock.


static WORD CDate::CurrentDay();

Returns a WORD which represents the current day of the month as taken from the system clock.


static LONG CDate::CurrentYear();

Returns a LONG which represents the current year as taken from the system clock.


static WORD CDate::CurrentDayOfWeek();

Returns a WORD which represents the current day of week as taken from the system clock.

Note:

1) The returned WORD is interpreted as defined in the Set() functions


static void CDate::SetBeginingDayOfWeek(WORD BeginOfWeek);

Sets the day of week the DTime classes will consider to be the beginning day of week. It uses this value in CDate::GetWeekOfYear() and CDate::GetWeekOfMonth()

Note:

1) The WORD is interpreted as defined in the Set() functions

2) The InitDTimeSettings function calls this function internally to modify the beginning day of week.


static WORD CDate::GetBeginingDayOfWeek();

Gets the day of week the DTime classes consider to be the beginning day of week. It uses this value in CDate::GetWeekOfYear() and CDate::GetWeekOfMonth()

Note:

1) The returned WORD is interpreted as defined in the Set() functions


static void CDate::SetEndJulianCalendar(LONG Year, WORD Month, WORD Day);

Sets when DTime functions consider the JULIAN calendar to be ended. Usually this will not need to be called as InitDTimeSettings will call this function with the value as set up by via the settings applet or environment variables.


static void CDate::SetBeginGregCalendar(LONG Year, WORD Month, WORD Day);

Sets when DTime functions consider the GREGORIAN calendar to begin. Usually this will not need to be called as InitDTimeSettings will call this function with the value as set up by via the settings applet or environment variables.


static DateS CDate::GetEndJulianCalendar();

Retrieves a DateS structure representation of when DTime functions consider the JULIAN calendar to be ended.


static DateS CDate::GetBeginGregCalendar();

Retrieves a DateS structure representation of when DTime functions consider the GREGORIAN calendar to begin.


static CDate CDate::FirstCurrentMonth();

Returns a CDate which represents the first of the current month as taken from the system clock.

See also CDate::LastCurrentMonth()


static CDate CDate::LastCurrentMonth();

Returns a CDate which represents the last of the current month as taken from the system clock.

See also CDate::FirstCurrentMonth()


static CDate CDate::FirstCurrentYear();

Returns a CDate which represents 1st January for this year as taken from the system clock.

See also CDate::LastThisYear()


static CDate CDate::LastCurrentYear();

Returns a CDate which represents 31st December for this year as taken from the system clock.

See also CDate::FirstThisYear()


static CDate CDate::JDEpoch();

Returns a CDate which represents Julian Day Epoch i.e. 1st January -4712


static CDate CDate::MJDEpoch();

Returns a CDate which represents 1st January -4712 + 2400000 Days (which corresponds to 17 November 1858)


static CDate CDate::Epoch1900();

Returns a CDate which represents 1st January 1900


static CDate CDate::Epoch1950();

Returns a CDate which represents 1st January 1950


static CDate CDate::EpochCTime();

Returns a CDate which represents a CTime of 0 seconds (i.e. 1st

January 1970)


static CDate CDate::Epoch2000();

Returns a CDate which represents 1st January 2000


static CDate CDate::GregorianEpoch();

Returns a CDate which represents when the change from the Julian to Gregorian calendar occurred. This value is modifiable and is dependent on how the classes have been initialised. This value can be changed via the settings applet and the InitDTimeSettings() function.


static CDate CDate::NewYearsDay(LONG Year = CDate::CurrentYear());

Returns a CDate which represents 1st January for this year as taken from the system clock.


static CDate CDate::ValentinesDay(LONG Year = CDate::CurrentYear());

Returns a CDate which represents Valentines Day i.e. 14th February.


static CDate CDate::AshWednesday(LONG Year = CDate::CurrentYear());

Returns a CDate which represents Ash Wednesday. This date is determined as Wednesday, 40 days prior to Easter Sunday.

See also:  	CDate::GoodFriday()

CDate::EasterSunday()


static CDate CDate::StPatricksDay(LONG Year = CDate::CurrentYear());

Returns a CDate which represents St Patrick’s Day i.e. 17th March.


static CDate CDate::GoodFriday(LONG Year = CDate::CurrentYear());

Returns a CDate which represents Good Friday. This date is determined as the Friday prior to Easter Sunday.

See also:  	CDate::AshWednesday()

CDate::EasterSunday()


static CDate CDate::EasterSunday(LONG Year = CDate::CurrentYear());

Returns a CDate which represents Easter Sunday. This date is determined using an algorithm by Spencer Jones in his book  “General Astronomy” in 1922. It has been published again in the “Journal of the British Astronomical Association” in 1977 where it is said that it was devised in 1876 and appeared in Butcher’s “Ecclesiastical Calendar“. It also handles calculating Easter in the Julian Calendar, The algorithm most recently appeared in the book “Astronomical Algorithms” by Jean Meeus.

See also:  	CDate::AshWednesday()

CDate::GoodFriday()


static CDate CDate::CanadaDay(LONG Year = CDate::CurrentYear());

Returns a CDate which represents Canada Day i.e. the 1st July.


static CDate CDate::IndependenceDay(LONG Year = CDate::CurrentYear());

Returns a CDate which represents American Independence Day i.e. the 4th July.


static CDate CDate::BastilleDay(LONG Year = CDate::CurrentYear());

Returns a CDate which represents Bastille Day i.e. the 14th July.


static CDate CDate::ChristmasDay(LONG Year = CDate::CurrentYear());

Returns a CDate which represents Christmas Day i.e. the 25th December.


static BOOL CDate::IsLeap(LONG Year);

returns TRUE if the year is leap otherwise FALSE.

The routine correctly allows for the exception whereby dates in the Gregorian calendar are leap (or bissextile) if divisible by 4 with the following exception: the centurial years that are not divisible by 400, such as 1700, 1800, 1900, and 2100, are not leap years. The other century years, which are divisible by 400, are leap years, for instance 1600, 2000 and 2400.


static WORD CDate::DaysInYear(LONG Year);

Returns the number of days in a year i.e. 366 if the year is leap otherwise 365


WORD CDate::DaysInMonth(WORD Month, BOOL IsLeap);

Returns the number of days in a month e.g. 31 for January, 28 for a common February, 29 for a leap February etc.


static WORD CDate::DaysSinceJan1(WORD Month, WORD Day, BOOL IsLeap);

Returns the number of days since 1st of January.


static WORD CDate::DaysSinceJan0(WORD Month, WORD Day, BOOL IsLeap);

Returns the number of days since 0th of January (previous 31st December).


static void CDate::SetDefaultFormat(const CString& Format);

Sets the default format the Format() function uses.

e.g.  CDate::SetDefaultFormat(“%D/%M/%Y”);

Note:

1) The InitDTimeSettings function calls this function internally to modify the default format string.


static CString& CDate::GetDefaultFormat();

Retrieves the default format the Format() function uses.


static BOOL CDate::InGregorianCalendar(LONG Year, WORD Month, WORD Day);

Returns whether the parameters which form a date is in the Gregorian calendar.


static BOOL CDate::SetDoConstructorAsserts(BOOL bDoAsserts);

Sets whether CDate Constructors and Set() functions asserts when invalid parameters are detected. The value returned is the previous state of the value

e.g.

BOOL bOldDoAsserts = CDate::SetDoConstructorAsserts(TRUE);

CDate x(1990, 1, 32);	//will assert and be stored as an invalid date

CDate::SetDoConstructorAsserts(bOldDoAsserts);


static CString& CDate::GetFullStringDayOfWeek(WORD DayOfWeek);

Returns a representation of the day of week parameter as a CString reference, returning for example “Sunday“, “Monday” etc.

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.

2) The WORD is interpreted as defined in the Set() functions.

See Also: CDate::GetAbrStringDayOfWeek


static CString& CDate::GetAbrStringDayOfWeek(WORD DayOfWeek);

Returns an abbreviated representation for the day of week parameter as a CString reference, returning for example “Sun“, “Mon” etc.

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.

2) The WORD is interpreted as defined in the Set() functions.

See Also: CDate::GetFullStringDayOfWeek


static CString& CDate::GetFullStringMonth(WORD Month);

Returns a CString representation for the month parameter, returning for example “January“, “February“ etc.

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.

See Also: CDate::GetAbrStringMonth


static CString& CDate::GetAbrStringMonth(WORD Month);

Returns a CString representation for the month parameter, returning for example “Jan“, “Feb“ etc.

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.

See Also: CDate::GetFullStringMonth


WORD CDate::DaysSinceJan1() const;

Returns the number of days since 1st of January for this instance.


WORD CDate::DaysSinceJan0() const;

Returns the number of days since 0th of January (previous 31st December) for this instance.


DateS CDate::GetDate() const;

Returns a DateS structure for this instance.


WORD CDate::GetDay() const;

Returns the Day of the month for this instance (1 - 31).


WORD CDate::GetMonth() const;

Returns the Month for this instance (1 - 12).


LONG CDate::GetYear() const;

Returns the Year for this instance.


LONG CDate::GetCEBCEYear(BOOL& IsCE) const;

Returns the Current Epoch / Before Current Epoch year for this instance.

e.g.

BOOL bIsCE;

CDate x(1990, 1, 32);

LONG y = x.GetCEBCEYear(bIsCE);	//y will be 1990, bIsCE will be TRUE

x.Set(-1990, 1, 32);

y = x.GetCEBCEYear(bIsCE);	//y will be 1989, bIsCE will be FALSE


LONG CDate::Get2DigitYear() const;

Returns the last 2 digits of the year.

e.g.

CDate x(1995, 1, 15);

LONG y = x.Get2DigitYear();

ASSERT(y == 95);


LONG CDate::Since1900Epoch() const;

Returns the number of days for this instance since 1st January 1900.


LONG CDate::Since1950Epoch() const;

Returns the number of days for this instance since 1st January 1950.


LONG CDate::SinceCTimeEpoch() const;

Returns the number of days for this instance since 1st January 1970.


LONG CDate::Since2000Epoch() const;

Returns the number of days for this instance since 1st January 2000.


LONG CDate::GDN() const;

Returns the number of days for this instance since the Gregorian Epoch.


LONG CDate::JD() const;

Returns the Julian Day or number of days for this instance since 1st January -4712.


BOOL CDate::IsLeap() const;

Returns TRUE if the year for this instance is leap otherwise FALSE.


WORD CDate::DaysInYear() const;

Returns the number of days for this instance’s year.


WORD CDate::DaysInMonth() const;

Returns the number of days for this instance’s month.


void CDate::AddMonth(int Months=1);

Adds a number of months to this instance.


void CDate::AddYear(int Years=1);

Adds a number of years to this instance.


void CDate::AddWeek(int Weeks=1);

Adds a number of weeks i.e. 7 days to this instance.


WORD CDate::GetDayOfWeek() const;

Returns the day of week for this instance. (1 for Sunday, 2 for Monday, and so forth).

Note:

1) See the Structures used by the classes for the enums compatible with how the day of week is returned from this member function.


CString& CDate::GetStringCEBCEYear() const;

Returns the CE/BCE Year for this instance as a CString reference.

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.


CString& CDate::GetFullStringDayOfWeek() const;

Returns the day of week for this instance as a CString reference.

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.

2) The WORD is interpreted as defined in the Set() functions.

See Also: CDate::GetAbrStringDayOfWeek


CString& CDate::GetAbrStringDayOfWeek() const;

Returns an abbreviated CString version for the day of week for this instance. e.g. “Sun“, “Mon” etc.

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.

2) The WORD is interpreted as defined in the Set() functions.

See Also: CDate::GetFullStringDayOfWeek


CString& CDate::GetFullStringMonth() const;

Returns the full CString version for the month for this instance. e.g. “January“, “February“ etc.

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.

2) The WORD is interpreted as defined in the Set() functions.

See Also: CDate::GetAbrStringMonth


CString& CDate::GetAbrStringMonth() const;

Returns an abbreviated CString version for the month for this instance. e.g. “Jan“, “Feb“ etc.

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.

1) 	The WORD is interpreted as defined in the Set() functions.

See Also: CDate::GetFullStringMonth


SYSTEMTIME CDate::GetSYSTEMTIME() const;

Returns a Win32 SDK SYSTEMTIME struct version of this instance.

Note:

1) The wDayOfWeek parameter of SYSTEMTIME is 0 based i.e. Sunday = 0, Monday = 1, and so on. This is unlike the WORD value returned from GetDayOfWeek member function.


tm CDate::GetTM() const;

Returns a c runtime tm struct version of this instance.


WORD CDate::GetWeekOfYear() const;

Returns the week of the year for this instance. As an example of how this is determined:

Suppose the 1st of January occurred on a Thursday and the day of week considered the beginning of the week is Monday. The following results would then be obtained:

Date	GetWeekOfYear()

Thursday 1st	0

Friday 2nd	0

Saturday 3rd	0

Sunday 4th	0

Monday 5th	1

Tuesday 6th	1

.

.

Monday 12th	2

.

.

.


WORD CDate::GetWeekOfMonth() const;

Returns the week of the month for this instance. As an example of how this is determined:

Suppose the 1st of the month occurred on a Thursday and the day of week considered the beginning of the week is Monday, The following results would then be obtained:

Date	GetWeekOfMonth()

Thursday 1st	0

Friday 2nd	0

Saturday 3rd	0

Sunday 4th	0

Monday 5th	1

Tuesday 6th	1

.

.

Monday 12th	2

.

.

.


BOOL CDate::IsValid() const;

Returns TRUE if this instance is valid otherwise FALSE.

e.g. 	CDate::SetDoConstructorAsserts(FALSE);

CDate Inval(1990, 151, 3);                 //an invalid month

ASSERT(IsValid(Inval) == FALSE);

See Also: 	CDate::SetDefaultFormat

CDate::SetDoConstructorAsserts


LONG CDate::Collate() const;

Returns a LONG which can be used in a database storage of this CDate.

e.g. 	CDate x(1978, 4, 3);

ASSERT(x.Collate = 197843L);


BOOL CDate::InGregorianCalendar() const;

Returns true if this instance is in the Gregorian calendar otherwise this instance is in the Julian calendar.


CDate CDate::FirstThisMonth() const;

Returns a CDate for the first of the month for this instance

e.g.  	CDate x(1990, 3, 4);

CDate f = x.FirstThisMonth();

ASSERT(f = CDate(1990, 3, 1);

See Also: CDate::LastThisMonth


CDate CDate::LastThisMonth() const;

Returns a CDate for the last of the month for this instance

e.g.  	CDate x(1990, 3, 4);

CDate f = x.LastThisMonth();

ASSERT(f = CDate(1990, 3, 31);

See Also: CDate::FirstThisMonth


CDate CDate::FirstThisYear() const;

Returns a CDate for the 1st January for this instance

e.g.  	CDate x(1990, 3, 4);

CDate f = x.FirstThisYear();

ASSERT(f = CDate(1990, 1, 1);

See Also: CDate::LastThisMonth


CDate CDate::LastThisYear() const;

Returns a CDate for the 31st December for this instance

e.g.  	CDate x(1990, 3, 4);

CDate f = x.LastThisYear();

ASSERT(f = CDate(1990, 12, 31);

See Also: CDate::FirstThisYear


CDate& CDate::operator=(const CDate& d);

Copies a CDate into this CDate and returns a reference to this

instance


CDate CDate::operator+(LONG Days) constCDate CDate::operator+(LONG Days) const
CDate CDate::operator+(LONG Days) const;

CDate CDate::operator-(LONG Days) const;

Standard arithmetic operators to add and subtracts a number of days.

e.g.  	CDate Tomorrow = CDate::GetCurrentDate() + 1;

LONG OneMonth = CDate(1990, 3, 4) - CDate(1990, 2, 4);

CDate Yesterday = CDate::GetCurrentDate() - 1;


CDate& CDate::operator+=(LONG Days)\n\rCDate& CDate::operator-=(LONG Days)
CDate& CDate::operator+=(LONG Days);

CDate& CDate::operator-=(LONG Days);

Standard arithmetic increment and decrement operators

e.g.  	CDate x(1990, 1, 1);

x += 7;

ASSERT(x == CDate(1990, 1, 8));

x -= 7;

ASSERT(x == CDate(1990, 1, 1));


CDate& CDate::operator++();

Standard arithmetic increment operator. Adds one day to this instance


CDate& CDate::operator--();

Standard arithmetic decrement operator. Subtracts one day from this instance.


BOOL CDate::operator==(const CDate& d) const;

BOOL CDate::operator>(const CDate& d) const;

BOOL CDate::operator>=(const CDate& d) const;

BOOL CDate operator<(const CDate& d) const;

BOOL CDate operator<=(const CDate& d) const;

BOOL CDate operator!=(const CDate& d) const;

Standard arithmetic equality operators.


virtual void CDate::AssertValid() const;

Standard MFC override which performs a validity check on this object by checking its internal state. This function is only available in the DEBUG version.

Note:

1) This function is called internally before any functions which modify the internal state of the instance.


virtual void CDate::Dump(CDumpContext& dc) const;

Standard MFC override to allow debugging output of the contents of this CDate. This simply calls the Format method with the default Format and sends the results to the CDumpContext.


CString& CDate::Format(const CString& sFormat=CDate::GetDefaultFormat()) const;

Generates a formatted string that corresponds to this CDate object.

The function supports the following formats:

%a	Abbreviated weekday name

%A	Full weekday name

%b	Abbreviated month name

%B	Full month name

%d	Day of month as decimal number (01 - 31)

%j	Day of year as decimal number (001 - 366)

%m	Month as decimal number (01 - 12)

%U	Week of year as decimal number

%w	Weekday as decimal number (1 - 7; Sunday is 1)

%x	Short date representation, appropriate to current locale

%y	Year without century, as decimal number (00 - 99)

%Y	Year with century, as decimal number

%c	Year displayed using C.E.(Current Epoch) / B.C.E (Before Current Epoch) convention e.g. -1023 = 1022 BCE

%#x	Long date representation, appropriate to current locale

%#d, %#j, %#m, %#U, %#y Remove leading zeros (if any)

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.

2) If the CDate is invalid then an empty string reference will be returned.


void CDate::Serialize(CArchive& ar);

Standard MFC override to allow streaming of this CDate to archive. The space taken is

exactly 6 bytes (4 data bytes + 2 schema bytes).


ostream &operator<<(ostream &os, const CDate &d);
ostream& CDate::operator<<(ostream &os, const CDate &d);

Generates a formatted string to io stream that corresponds to this CDate object using the default format as specified by CDate::SetDefaultFormat


friend CArchive& operator<<(CArchive& ar, CDate& Date);

Simply calls the Serialize method of “Date”, asserting that the archive “ar” is storing.


friend CArchive& operator>>(CArchive& ar, CDate& Date);

Simply calls the Serialize method of “Date”, asserting that the archive “ar” is loading.


CLTimeSpan Index

Construction

CLTimeSpan

Constructs CLTimeSpan objects in various ways.

Setting

Set

Allows you to set the value after its constructor has been called.

Static Constructors

OneCivilYear

Creates a CLTimeSpan object that represents one civil year.

OneDay

Creates a CLTimeSpan object that represents one day.

OneHour

Creates a CLTimeSpan object that represents one hour.

OneMinute

Creates a CLTimeSpan object that represents one minute.

OneSecond

Creates a CLTimeSpan object that represents one second.

OneMilliSecond

Creates a CLTimeSpan object that represents one millisecond.

Static Operations

SetDefaultFormat

Sets the default display format.

GetDefaultFormat

Retreives the default display format.

SetDoConstructorAsserts

Sets whether or not ASSERTS are used.

Operations

GetTotalDays

Returns the total number of days.

GetHours

Returns the number of hours.

GetMinutes

Returns the number of minutes.

GetSeconds

Returns the number of seconds.

GetMilliSeconds

Returns the number of milliseconds.

IsValid

Returns true if this CLTimeSpan is a valid date, false if not.

Negate

Inverts the sign of this CLTimeSpan.

IsPositiveSpan

Returns the sign of this CLTimeSpan

SecondsAsDouble

Returns the number of seconds this CLTimeSpan.

Overloaded Arithmetic Operators

operator=

Assigns new date values.

operator+,-

Add and subtract CLTimeSpan objects.

operator+=.-=

Add and subtract a time span to and from this CLTimeSpan object.

operator*, /

Multiples and divides CLTimeSpan objects.

operator*=, /=

Multiples and divides this CLTimeSpan object.

Overloaded Equality Operators

operator==, > etc.

Compares two CLTimeSpans.

Diagnostics / Debug

AssertValid

Validates this object's integrity

Dump

Produces a diagnostic dump of this object.

Display

Format

Converts a CLTimeSpan object into a formatted string.

Streaming

Serialize

Loads or stores a CLTimeSpan from/to a MFC archive.

operator<<

Outputs a CLTimeSpan to a C++ io stream.

operator<<

Stores a CLTimeSpan on a MFC CArchive.

operator>>

Loads a CLTimeSpan from a MFC CArchive.


CLTimeSpan Constructors

CLTimeSpan::CLTimeSpan();

CLTimeSpan::CLTimeSpan(LONG Day, WORD Hour, WORD Minute, WORD Second, WORD MilliSecond );

CLTimeSpan::CLTimeSpan(const CLTimeSpan& lts);

CLTimeSpan::CLTimeSpan(const CTimeSpan& ts);

CLTimeSpan::CLTimeSpan(const CLTimeOfDay& tod);

CLTimeSpan::CLTimeSpan(const double& Seconds);

CLTimeSpan::CLTimeSpan(const COleDateTimeSpan& oleTimeSpan);

Parameters

lts:	Indicates a CLTimeSpan object that already exists.

ts:	Indicates a CTimeSpan object that already exists.

tod:	Indicates a CLTimeOfDay object that already exists.

Seconds:	Indicates a count of seconds as a double.

oleTime:	An OLE timespan.

Note:

1) The default constructor creates an invalid CLTimeSpan

2) if sm_bDoAsserts is set (via SetDoConstructorAsserts), the constructors will assert in debug mode if any of the parameters are invalid.

3) The constructor involving the OLE timespan is only available under 32 bit Windows.


CLTimeSpan Set routines
CLTimeSpan Set functions

CLTimeSpan& CLTimeSpan::Set();

CLTimeSpan& CLTimeSpan::Set(LONG Day, WORD Hour, WORD Minute, WORD Second, WORD MilliSecond );

CLTimeSpan& CLTimeSpan::Set(const CLTimeSpan& lts);

CLTimeSpan& CLTimeSpan::Set(const CTimeSpan& ts);

CLTimeSpan& CLTimeSpan::Set(const CLTimeOfDay& tod);

CLTimeSpan& CLTimeSpan::Set(const double& Seconds);

CLTimeSpan& CLTimeSpan::Set(const COleDateTimeSpan& oleTimeSpan);

Return Value

A reference to this instance.

Parameters

See CLTimeSpan Constructors

Note:

1) These functions are actually called by the constructors. They allow a CLTimeSpan’s value to be modified even after construction.

2) The set function involving the OLE timespan is only available under 32 bit Windows.


static CLTimeSpan CLTimeSpan::OneCivilYear();

Returns a CLTimeSpan which represents a civil year i.e. 365 days and 6 hours


static CLTimeSpan CLTimeSpan::OneDay();

Returns a CLTimeSpan which represents one day.


static CLTimeSpan CLTimeSpan::OneHour();

Returns a CLTimeSpan which represents one hour.


static CLTimeSpan CLTimeSpan::OneMinute();

Returns a CLTimeSpan which represents one minute.


static CLTimeSpan CLTimeSpan::OneSecond();

Returns a CLTimeSpan which represents one second.


static CLTimeSpan CLTimeSpan::OneMilliSecond();

Returns a CLTimeSpan which represents one millisecond.


static void CLTimeSpan::SetDefaultFormat(const CString& Format);

Sets the default format the Format() function uses.

e.g.  CLTimeSpan::SetDefaultFormat(“%D %H:%M:%S:%F”);

Note:

1) The InitDTimeSettings function calls this function internally to modify the default format string.


static CString& CLTimeSpan::GetDefaultFormat();

Retreives the default format the Format() function uses.


static BOOL CLTimeSpan::SetDoConstructorAsserts(BOOL bDoAsserts);

Sets whether CLTimeSpan Constructors and Set() functions asserts when invalid parameters are detected. The value returned is the previous state of the value


LONG CLTimeSpan::GetTotalDays() const;

Returns the total number of days this CLTimeSpan contains.

e.g.  CLTimeSpan x(10, 12 , 13, 14, 15)

ASSERT(x.GetTotalDays() == 10);


WORD CLTimeSpan::GetHours() const;

Returns the number of hours this CLTimeSpan contains.

e.g.  CLTimeSpan x(10, 12 , 13, 14, 15)

ASSERT(x.GetHours() == 12);


WORD CLTimeSpan::GetMinutes() const;

Returns the number of minutes this CLTimeSpan contains.

e.g.  CLTimeSpan x(10, 12 , 13, 14, 15)

ASSERT(x.GetMinutes() == 13);


WORD CLTimeSpan::GetSeconds() const;

Returns the number of seconds this CLTimeSpan contains.

e.g.  CLTimeSpan x(10, 12 , 13, 14, 15)

ASSERT(x.GetSeconds() == 14);


WORD CLTimeSpan::GetMilliSeconds() const;

Returns the number of milliseconds this CLTimeSpan contains.

e.g.  CLTimeSpan x(10, 12 , 13, 14, 15)

ASSERT(x.GetMilliSeconds() == 15);


BOOL CLTimeSpan::IsValid() const;

Returns TRUE if this instance is valid otherwise FALSE.

e.g. 	CLTimeSpan::SetDoConstructorAsserts(FALSE);

CLTimeSpan Inval;

ASSERT(IsValid(Inval) == FALSE);

See Also: 	CLTimeSpan::SetDefaultFormat

CLTimeSpan::SetDoConstructorAsserts


CLTimeSpan& CLTimeSpan::Negate();

Negates this CLTimeSpan and returns a reference to it.

e.g.  CLTimeSpan x(10, 12 , 13, 14, 15)

        x.Negate();

        ASSERT(x == CLTimeSpan(-10, 12, 13, 14, 15);


BOOL CLTimeSpan::IsPositiveSpan() const;

Returns true if this CLTimeSpan represents a positive time span else negative.

e.g.  CLTimeSpan x(-10, 12 , 13, 14, 15)

        ASSERT(!x.IsPositiveSpan());


double CLTimeSpan::SecondsAsDouble() const;

Returns the underlying number of seconds this CLTimeSpan contains as a double.


CLTimeSpan& CLTimeSpan::operator=(const CLTimeSpan& TimeSpan)

Copies a CLTimeSpan into this CLTimeSpan and returns a reference to this instance


CLTimeSpan CLTimeSpan::operator+(const CLTimeSpan& TimeSpan) const;

CLTimeSpan CLTimeSpan::operator-(const CLTimeSpan& TimeSpan) const;

Standard arithmetic operators to add and subtracts CLTimeSpan’s.


CLTimeSpan& CLTimeSpan::operator+=(const CLTimeSpan& TimeSpan);

CLTimeSpan& CLTimeSpan::operator-=(CLTimeSpan& TimeSpan);

Standard arithmetic auto increment and decrement operators.


CLTimeSpan CLTimeSpan::operator*(WORD Multiplier) const;

CLTimeSpan operator*(WORD Multiplier, const CLTimeSpan& TimeSpan);

CLTimeSpan CLTimeSpan::operator/(WORD divisor) const;

Standard arithmetic operators to multiply and divide CLTimeSpan’s.


CLTimeSpan& CLTimeSpan::operator*=(WORD Multiplier);

CLTimeSpan& CLTimeSpan::operator/=(WORD Divisor);

Standard arithmetic auto multiply and divide operators.


BOOL CLTimeSpan::operator==(const CLTimeSpan& TimeSpan) const;

BOOL CLTimeSpan::operator>(const CLTimeSpan& TimeSpan) const;

BOOL CLTimeSpan::operator>=(const CLTimeSpan& TimeSpan) const;

BOOL CLTimeSpan::operator<(const CLTimeSpan& TimeSpan) const;

BOOL CLTimeSpan::operator<=(const CLTimeSpan& TimeSpan) const;

BOOL CLTimeSpan::operator!=(const CLTimeSpan& TimeSpan) const;

Standard arithmetic equality operators.


virtual void CLTimeSpan::AssertValid() const;

Standard MFC override which performs a validity check on this object by checking its internal state. This function is only available in the DEBUG version.

Note:

1) This function is called internally before any functions which modify the internal state of the instance.


virtual void CLTimeSpan::Dump(CDumpContext& dc) const;

Standard MFC override to allow debugging output of the contents of this CLTimeSpan. This simply calls the Format method with the default Format and sends the results to the CDumpContext.


CString& CLTimeSpan::Format(const CString& sFormat=CLTimeSpan:: GetDefaultFormat()) const;

Generates a formatted string that corresponds to this CLTimeSpan object.

The function supports the following formats:

%D    Total days in this CLTimeSpan

%H    Hours in this CLTimeSpan (00 - 23)

%M    Minutes in the current hour in this CLTimeSpan (00 - 59)

%S    Seconds in the current minute in this CLTimeSpan (00 - 59)

%F    MilliSeconds in the current second in this CLTimeSpan (000 - 999)

%%    Percent sign

%#H, %#M, %#S  Remove leading zeros (if any).

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.

2) If the CLTimeSpan is invalid then an empty string reference will be returned


void CLTimeSpan::Serialize(CArchive& ar)
void CLTimeSpan::Serialize(CArchive& ar);

Standard MFC override to allow streaming of this CLTimeSpan to archive. The space taken is

exactly 12 bytes (10 data bytes + 2 schema bytes).


ostream& CLTimeSpan::operator<<(ostream &os, const CLTimeSpan& TimeSpan);

Generates a formatted string to io stream that corresponds to this CLTimeSpan object using the default format as specified by CLTimeSpan::SetDefaultFormat


friend CArchive& operator<<(CArchive& ar, CLTimeSpan& TimeSpan);

Simply calls the Serialize method of “TimeSpan”, asserting that the archive “ar” is storing.


friend CArchive& operator>>(CArchive& ar, CLTimeSpan& TimeSpan);

Simply calls the Serialize method of “TimeSpan”, asserting that the archive “ar” is loading.


CLTimeOfDay Index

Constructors

CLTimeOfDay

Constructs CLTimeOfDay objects in various ways.

Setting

Set

Allows you to set the value after its constructor has been called.

Static Constructors

CurrentTimeOfDay

Creates a CLTimeOfDay object that represents the current time.

Midnight

Creates a CLTimeOfDay object that represents midnight.

Midday

Creates a CLTimeOfDay object that represents midday.

Static Operations

SetDefaultFormat

Sets the default display format.

GetDefaultFormat

Retreives the default display format.

SetDoConstructorAsserts

Sets whether or not ASSERTS are used.

Operations

GetHour

Returns the number of hours.

GetMinute

Returns the number of minutes.

GetSecond

Returns the number of seconds.

GetTotalSeconds

Returns the total number of seconds.

GetMilliSecond

Returns the number of milliseconds.

GetAMPMHour

Returns the hour as an AM / PM hour.

GetAMPMString

Returns the AM / PM String indicator.

IsValid

Returns true if this CLTimeOfDay is a valid date, false if not.

Collate

Provides a numeric output suitable for database storage and use.

GetSYSTEMTIME

Returns a SYSTEMTIME representation of this CLTimeOfDay

GetTM

Returns a “C” runtime tm representation.

SecondsAsDouble

Returns the underlying count of seconds this CLTimeOfDay represents.

Overloaded Arithmetic Operators

operator=

Assigns new time of day values.

operator+,-

Add and subtract CLTimeOfDay objects.

operator+=.-=

Add and subtract a CTimeOfDays to and from this CLTimeOfDay object.

Overloaded Equality Operators

operator==, > etc

Compares two CLTimeOfDays.

Diagnostics / Debug

AssertValid

Validates this object's integrity

Dump

Produces a diagnostic dump of this object.

Display

Format

Converts a CLTimeSpan object into a formatted string.

Streaming

Serialize

Loads or stores a CLTimeOfDay from/to a MFC archive.

operator<<

Outputs a CLTimeOfDay to a C++ io stream.

operator<<

Stores a CLTimeOfDay on a MFC CArchive.

operator>>

Loads a CLTimeOfDay from a MFC CArchive.


CLTimeOfDay Constructors

CLTimeOfDay::CLTimeOfDay();

CLTimeOfDay::CLTimeOfDay(WORD Hour, WORD Minute, WORD Second, WORD MilliSecond);

CLTimeOfDay::CLTimeOfDay(const SYSTEMTIME& st);

CLTimeOfDay::CLTimeOfDay(const CLTimeOfDay& ltod);

CLTimeOfDay::CLTimeOfDay(DWORD TotalSeconds, WORD MilliSecond);

CLTimeOfDay::CLTimeOfDay(const double& Seconds);

Parameters

st	A Win32 SYSTEMTIME structure.

tod	Indicates a CLTimeOfDay object that already exists.

TotalSeconds	Indicates a accumulated number of seconds.

Seconds 	Indicates a count of seconds as a double.

Note:

1) The default constructor creates an invalid CLTimeOfDay

2) if sm_bDoAsserts is set (via SetDoConstructorAsserts), the constructors will assert in debug mode if any of the parameters are invalid


CLTimeOfDay Set routines
CLTimeOfDay Set functions

CLTimeOfDay& CLTimeOfDay::Set();

CLTimeOfDay& CLTimeOfDay::Set(WORD Hour, WORD Minute, WORD Second, WORD MilliSecond);

CLTimeOfDay& CLTimeOfDay::Set(const SYSTEMTIME& st);

CLTimeOfDay& CLTimeOfDay::Set(const CLTimeOfDay& ltod);

CLTimeOfDay& CLTimeOfDay::Set(DWORD TotalSeconds, WORD MilliSecond);

CLTimeOfDay& CLTimeOfDay::Set(const double& Seconds);

Return Value

A reference to this instance.

Parameters

See CLTimeOfDay Constructors

Note:

1) The default constructor creates an invalid CLTimeOfDay

2) if sm_bDoAsserts is set (via SetDoConstructorAsserts), the constructors will assert in debug mode if any of the parameters are invalid.

5) These functions are actually called by the constructors. They allow a CLTimeOfDay’s value to be modified even after construction


static CLTimeOfDay CurrentTimeOfDay(TimeFrame tf);
static CLTimeOfDay CLTimeOfDay::CurrentTimeOfDay(TimeFrame tf);

Returns a CLTimeOfDay which represents the current time of day as taken from the system clock. The time used is interpreted depending on the timeframe parameter tf.

See Also	Structures / Enums used by the Classes


static CLTimeOfDay Midnight();
static CLTimeOfDay CLTimeOfDay::Midnight();

Returns a CLTimeOfDay which represents midnight.


static CLTimeOfDay Midday();
static CLTimeOfDay CLTimeOfDay::Midday();

Returns a CLTimeOfDay which represents midday.


static void CLTimeOfDay::SetDefaultFormat(const CString& Format);

Sets the default format the Format() function uses.

e.g.  	CLTimeOfDay::SetDefaultFormat(“%H:%M:%S.%F”);

Note:

1) The InitDTimeSettings function calls this function internally to modify the default format string.


static CString& CLTimeOfDay::GetDefaultFormat();

Retreives the default format the Format() function uses.


static BOOL CLTimeOfDay::SetDoConstructorAsserts(BOOL bDoAsserts);

Sets whether CLTimeOfDay Constructors and Set() functions asserts when invalid parameters are detected. The value returned is the previous state of the value


WORD CLTimeOfDay::GetHours() const;
WORD CLTimeOfDay::GetHour() const;

Returns the number of hours this CLTimeOfDay contains.

e.g.  	CLTimeOfDay x(12 , 13, 14, 15)

ASSERT(x.GetHour() == 12);


WORD CLTimeOfDay::GetMinute() const;

Returns the number of minutes this CLTimeOfDay contains.

e.g.  	CLTimeOfDay x(12 , 13, 14, 15)

ASSERT(x.GetMinute() == 13);


WORD CLTimeOfDay::GetSecond() const;

Returns the number of seconds this CLTimeOfDay contains.

e.g.  	CLTimeOfDay x(12 , 13, 14, 15)

ASSERT(x.GetSecond() == 14);


DWORD CLTimeOfDay::GetTotalSeconds() const;

Returns the total number of seconds this CLTimeOfDay contains.

e.g.  	CLTimeOfDay x(0 , 1, 14, 15)

ASSERT(x.GetTotalSeconds() == 74);


WORD CLTimeSpan::GetMilliSecond() const;
WORD CLTimeOfDay::GetMilliSecond() const;

Returns the number of milliseconds this CLTimeOfDay contains.

e.g.  	CLTimeOfDay x(12 , 13, 14, 15)

ASSERT(x.GetMilliSecond() == 15);


WORD  CLTimeOfDay::GetAMPMHour() const;

Returns the 12 hour version of the hour this CLTimeOfDay represents.

e.g.  	CLTimeOfDay x(17 , 13, 14, 15)

ASSERT(x.GetAMPMHour() == 5);


CString& CLTimeOfDay::GetAMPMString() const;

Returns the string to indicate whether this CLTimeOfDay is before or after midday.


BOOL CLTimeOfDay::IsValid() const;

Returns TRUE if this instance is valid otherwise FALSE.

e.g. 	CLTimeOfDay::SetDoConstructorAsserts(FALSE);

CLTimeOfDay Inval;

ASSERT(IsValid(Inval) == FALSE);

See Also: 	CLTimeOfDay::SetDefaultFormat

CLTimeOfDay::SetDoConstructorAsserts


ULARGE_INTEGER CLTimeOfDay::Collate() const;

Returns a ULARGE_INTEGER which can be used in a database storage of this CLTimeOfDay.


SYSTEMTIME CLTimeOfDay::GetSYSTEMTIME() const;

Returns a SYSTEMTIME structure representing this CLTimeOfDay

Note:

1) Only the wHour, wMinute, wSecond & wMilliSecond parameters of SYSTEMTIME are filled in. All the other values are set to 0.


tm CLTimeOfDay::GetTM() const;

Returns a c runtime tm struct version of this instance.


double CLTimeOfDay::SecondsAsDouble() const;

Returns the underlying number of seconds this CLTimeOfDay contains as a double.


CLTimeOfDay& CLTimeOfDay::operator=(const CLTimeOfDay& TimeSpan)
CLTimeOfDay& CLTimeOfDay::operator=(const CLTimeOfDay& Tod);

Copies a CLTimeOfDay into this CLTimeOfDay and returns a reference to this instance.


CLTimeOfDay CLTimeOfDay::operator+(const CLTimeSpan& TimeSpan) const;

CLTimeOfDay CLTimeOfDay::operator-(const CLTimeSpan& TimeSpan) const;

Standard arithmetic operators to add and subtracts CLTimeOfDay’s.


CLTimeOfDay& CLTimeOfDay::operator+=(const CLTimeSpan& TimeSpan);

CLTimeSpan& CLTimeOfDay::operator-=(CLTimeSpan& TimeSpan);

Standard arithmetic auto increment and decrement operators.


BOOL CLTimeOfDay::operator==(const CLTimeOfDay& Tod) const;

BOOL CLTimeOfDay::operator>(const CLTimeOfDay& Tod) const;

BOOL CLTimeOfDay::operator>=(const CLTimeOfDay& Tod) const;

BOOL CLTimeOfDay::operator<(const CLTimeOfDay& Tod) const;

BOOL CLTimeOfDay::operator<=(const CLTimeOfDay& Tod) const;

BOOL CLTimeOfDay::operator!=(const CLTimeOfDay& Tod) const;

Standard arithmetic equality operators.


virtual void CLTimeOfDay::AssertValid() const;

Standard MFC override which performs a validity check on this object by checking its internal state. This function is only available in the DEBUG version.

Note:

1) This function is called internally before any functions which modify the internal state of the instance.


virtual void CLTimeOfDay::Dump(CDumpContext& dc) const;

Standard MFC override to allow debugging output of the contents of this CLTimeOfDay. This simply calls the Format method with the default Format and sends the results to the CDumpContext.


CString& CLTimeOfDay::Format(const CString& sFormat=CLTimeOfDay:: GetDefaultFormat()) const;

Generates a formatted string that corresponds to this CLTimeOfDay object.

The function supports the following formats:

%H    Hours in the current day

%M    Minutes in the current hour

%h    12 Hour format Hours in this CLTimeSpan (00 - 12)

%P    AM / PM indicator

%S    Seconds in the current minute

%F    MilliSeconds in the current second

%%    Percent sign

%x    Time Of Day representation for current locale

%#H, %#h, %#M, %#S  Remove leading zeros (if any).

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.

2) If the CLTimeOfDay is invalid then an empty string reference will be returned


void CLTimeOfDay::Serialize(CArchive& ar)
void CLTimeOfDay::Serialize(CArchive& ar);

Standard MFC override to allow streaming of this CLTimeOfDay to archive. The space taken is

exactly 8 bytes (6 data bytes + 2 schema bytes).


ostream& CLTimeSpan::operator<<(ostream &os, const CLTimeOfDay& TimeSpan);
ostream& CLTimeOfDay::operator<<(ostream &os, const CLTimeOfDay& Tod);

Generates a formatted string to io stream that corresponds to this CLTimeOfDay object using the default format as specified by CLTimeOfDay::SetDefaultFormat


friend CArchive& operator<<(CArchive& ar, CLTimeSpan& Tod);

Simply calls the Serialize method of “Tod”, asserting that the archive “ar” is storing.


friend CArchive& operator>>(CArchive& ar, CLTimeSpan& Tod);

Simply calls the Serialize method of “Tod”, asserting that the archive “ar” is loading.


CLDate Index

Constructors

CLDate

Constructs CLDate objects in various ways.

Seting

Set

Allows you to set the value after its constructor has been called.

Static Constructors

CurrentTime

Creates a CLDate object that represents the current date and time.

Static Operations

SetDefaultFormat

Sets the default display format.

GetDefaultFormat

Retreives the default display format.

DeltaT

Retrieves the time span difference between the UCT and ET time frames.

CurrentlyInDST

Returns true if the current time is in Daylight time.

DaylightBias

Returns the time span difference between Standard time and Daylight time.

TimezoneBias

Returns the time span difference between the LOCAL and UCT time frames.

DaylightName

Returns the name associated with Daylight Time.

StandardName

Returns the name associated with Standard Time.

SetDoConstructorAsserts

Sets whether or not ASSERTS are used.

Operations

GetCDate

Returns the CDate part of this CLDate.

GetCLTimeOfDay

Returns the CLTimeOfDay part of this CLDate.

GetDate

Breaks down a CLDate object into components.

GetSYSTEMTIME

Returns a SYSTEMTIME representation of this CLDate.

GetTM

Returns a “C” runtime tm representation.

AddYear

Adds a number of years to this CLDate.

AddWeek

Adds a number of weeks to this CLDate.

AddMonth

Adds a number of month to this CLDate.

IsValid

Returns true if this CLDate is a valid date, false if not.

DeltaT

Retrieves the time span difference between the UCT and ET time frames for this CLDate.

SetTimeFrame

Sets the time frame this CLDate represents.

GetTimeFrame

Retrieves the time frame this CLDate represents.

IsDST

Returns true if this CLDate is in Daylight time.

GetStringTimeFrame

Returns a string representation of the time frame this CLDate represents.

GDNAsDouble

Returns the Gregorian Day Number of this CLDate.

GSNAsDouble

Returns the Gregorian Second Number of this CLDate.

Overloaded Arithmetic Operators

operator=

Assigns new CLDate values.

operator+,-

Add and subtract CLDate objects.

operator+=.-=

Add and subtract a CLDate’s to and from this CLDate object.

operator++

Adds one day to this CLDate object.

operator--

Subtracts one day from this CLDate object.

Overloaded Equality Operators

operator==, > etc

Compares two CLDates.

Diagnostics / Debug

AssertValid

Validates this object's integrity

Dump

Produces a diagnostic dump of this object.

Display

Format

Converts a CLDate object into a formatted string.

Streaming

Serialize

Loads or stores a CLDate from/to a MFC archive.

operator<<

Outputs a CLDate to a C++ io stream.

operator<<

Stores a CLDate on a MFC CArchive.

operator>>

Loads a CLDate from a MFC CArchive.


CLDate Constructors

CLDate();

CLDate(LONG Year, WORD Month, WORD Day,

         WORD Hour, WORD Minute, WORD Second,

         WORD MilliSecond, TimeFrame tf);

CLDate(const SYSTEMTIME& st, TimeFrame tf, BOOL bUseDayOfWeek=FALSE);

CLDate(LONG Year, WORD Month, WORD WeekOfMonth,

         WORD DayOfWeek, WORD Hour, WORD Minute, WORD Second,

         WORD MilliSecond, TimeFrame tf);

CLDate(LONG Days, CDate::DateEpoch e, WORD Hour, WORD Minute,

         WORD Second, WORD MilliSecond, TimeFrame tf);

CLDate(const CLDate& ld);

CLDate(const CTime& ct);

CLDate(const CDate& Date, const CLTimeOfDay& Tod, TimeFrame tf);

CLDate(const COleDateTime& oleTime, TimeFrame tf);

Parameters

tf:	An enum representing the time frame to use

st:	A Win32 SDK SYSTEMTIME structure.

bUseDayOfWeek:	Indicates whether to use the wDayOfWeek SYSTEMTIME parameter and use the wDay parameter as the week number.

ld:	Indicates a CLDate object that already exists.

ct:	Indicates a CTime object that already exists.

WeekOfMonth: 	The week of the month (0 - 5).

DayOfWeek : 	The day of the week e.g. SUNDAY.

oleTime:	An OLE Date.

Note:

1) The default constructor creates an invalid CLDate

2) if sm_bDoAsserts is set (via SetDoConstructorAsserts), the constructors will assert in debug mode if any of the parameters are invalid

3) if WeekOfMonth is 5 then it means the last week in the month. This is similar to the way the Win32 SDK operates.

4) The constructor involving the OLE date is only available under 32 bit Windows.


CLDate Set functions

CLDate& CLDate::Set();

CLDate& CLDate::Set(LONG Year, WORD Month, WORD Day,

              WORD Hour, WORD Minute, WORD Second,

              WORD MilliSecond, TimeFrame tf);

CLDate& CLDate::Set(const SYSTEMTIME& st, TimeFrame tf, BOOL bUseDayOfWeek=FALSE);

CLDate& CLDate::Set(LONG Year, WORD Month, WORD WeekOfMonth,

              WORD DayOfWeek, WORD Hour, WORD Minute, WORD Second,

              WORD MilliSecond, TimeFrame tf);

CLDate& CLDate::Set(LONG Days, CDate::DateEpoch e, WORD Hour, WORD Minute,

              WORD Second, WORD MilliSecond, TimeFrame tf);

CLDate& CLDate::Set(const CTime& ct);

CLDate& CLDate::Set(const CDate& Date, const CLTimeOfDay& Tod, TimeFrame tf);

CLDate& CLDate::Set(const COleDateTime& oleTime, TimeFrame tf);

Return Value

A reference to this instance.

Parameters

See CLDate Constructors

Note:

1) These functions are actually called by the constructors. They allow a CLDate’s value to be modified even after construction.

2) The set function involving the OLE date is only available under 32 bit Windows.


static CLDate CLDate::GetCurrentTime(Timeframe tf);

Returns a CLDate which represents the current date as taken from the system clock. The date used is interpreted depending on the time frame parameter tf.

See Also	Structures / Enums used by the Classes


static void CLDate::SetDefaultFormat(const CString& Format);

Sets the default format the Format() function uses.

e.g.  	CLDate::SetDefaultFormat(“%H:%M:%S.%F”);

Note:

1) The InitDTimeSettings function calls this function internally to modify the default format string.


static CString& CLDate::GetDefaultFormat();

Retreives the default format the Format() function uses.


static CLTimeSpan CDate::DeltaT(CLDate& ld);

Returns the timespan difference between UCT (GMT) and ET (Ephemeris Time) where DeltaT is defined as:

DeltaT = ET - UCT

e.g. CLTimeSpan dt = CDate::DeltaT(CLDate::GetCurrentTime(LOCAL));

Note:

1) This routines uses a look up table between the years 1620 to 1992 and values are extrapolated outside of this range using a power series.


static BOOL CLDate::CurrentlyInDST()

Returns whether the current system time is in Daylight time.


static CLTimeSpan CLDate::DaylightBias();

Returns the timespan difference between Standard time and Daylight time currently in effect where:

UCT = Local Time - TimeZoneBias() - [ DaylightBias() ]


static CLTimeSpan CLDate::TimezoneBias();

Returns the timespan difference between UCT and Local time currently in effect where:

UCT = Local Time - TimeZoneBias() - [ DaylightBias() ]


static CString& CLDate::DaylightName();

Returns a string associated with Daylight time. For example, this parameter could contain "EST" to indicate Eastern Standard Time.

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.


static CString& CLDate::StandardName();

Returns a string associated with Standard time. For example, this parameter could contain "PDT" to indicate Pacific Daylight Time.

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.


static BOOL CLDate::SetDoConstructorAsserts(BOOL bDoAsserts);

Sets whether CLDate Constructors and Set() functions asserts when invalid parameters are detected. The value returned is the previous state of the value


CDate CLDate::GetCDate() const;

Returns a CDate which represents the date part of this instance. Allows co-ordinated access to all the range of CDate functions.

Note:

1) Changes to the returned CDate are not reflected in the underlying CLDate.


CLTimeOfDay CLDate::GetCLTimeOfDay() const;

Returns a CLTimeOfDay which represents the time of day part of this long date. Allows co-ordinated access to all the range of CLTimeOfDay functions.

Note:

1) Changes to the returned CLTimeOfDay are not reflected in the underlying CLDate.


DateLS CLDate::GetDate() const;

Returns a DateLS structure for this instance.


SYSTEMTIME CLDate::GetSYSTEMTIME() const;

Returns a Win32 SDK SYSTEMTIME struct version of this instance.


tm CLDate::GetTM() const;

Returns a c runtime tm struct version of this instance.


void CLDate::AddMonth(int Months=1);

Adds a number of months to this instance.


void CLDate::AddYear(int Years=1);

Adds a number of years to this instance.


void CLDate::AddWeek(int Weeks=1);

Adds a number of weeks i.e. 7 days to this instance.


BOOL CLDate::IsValid() const;

Returns TRUE if this instance is valid otherwise FALSE.

e.g. 	CLDate::SetDoConstructorAsserts(FALSE);

CLDate Inval;

ASSERT(IsValid(Inval) == FALSE);

See also: 	CLDate::SetDefaultFormat

CLDate::SetDoConstructorAsserts


CLTimeSpan CLDate::DeltaT();

Returns the timespan difference between UCT (GMT) and ET (Ephemeris Time) for this instance.

See also: 	static CLTimeSpan CLDate::DeltaT


TimeFrame CLDate::SetTimeFrame(TimeFrame tf);

Modifies this instance to represent the same instance in time, but represented in another time frame. This functions allows you to convert from any one of the three time frames to any other. It works very similar to the Win32 SDK call SystemTimeToTzSpecificLocalTime (which is not available on Windows 95).


TimeFrame CLDate::GetTimeFrame() const;

Returns the time frame this CLDate represents.


BOOL CLDate::IsDST()

Returns whether this CLDate is in Daylight time.


CString& CLDate::GetStringTimeFrame() const;

Returns a string representation of the time frame for this CLDate.

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.


double CLDate::GDNAsDouble() const;

Returns a double representation of the number of days for this instance since the Gregorian Epoch.


double CLDate::GSNAsDouble() const;

Returns a double representation of the number of seconds for this instance since the Gregorian Epoch.


CLDate& CLDate::operator=(const CLDate& ld)
CLDate& CLDate::operator=(const CLDate& ld);

Copies a CLDate into this CLDate and returns a reference to this instance.


CLDate  CLDate::operator+(const CLTimeSpan& ts) const;
CLDate CLDate::operator+(const CLTimeSpan& ts);

CLTimeSpan CLDate::operator-(const CLDate& ld);

CLDate CLDate::operator-(const CLTimeSpan& ts);

Standard arithmetic operators to add and subtracts CLDate’s.


CLDate& CLDate::operator+=(const CLTimeSpan & ts)\n\rCLDate& CLDate::operator-=(const CLTimeSpan& ts)
CLDate& CLDate::operator+=(const CLTimeSpan& ts);

CLDate& CLDate::operator-=(const CLTimeSpan& ts);

Standard auto increment and decrement operators.


CLDate& CLDate::operator++();

Standard arithmetic increment operator. Adds one day to this instance


CLDate& CLDate::operator--();

Standard arithmetic decrement operator. Subtracts one day from this instance.


BOOL CLDate::operator==(CLDate& ld);

BOOL CLDate::operator>(CLDate& ld);

BOOL CLDate::operator>=(CLDate& ld);

BOOL CLDate operator<(CLDate& ld);

BOOL CLDate operator<=(CLDate& ld);

BOOL CLDate operator!=(CLDate& ld);

Standard arithmetic equality operators.

Note:

1) These functions and their parameters are not const as they may need to have their time frames modified during the comparison operation performed inside the functions. Any modifications are undone prior to returning from the functions.


virtual void CLDate::AssertValid() const;

Standard MFC override which performs a validity check on this object by checking its internal state. This function is only available in the DEBUG version.

Note:

1) This function is called internally before any functions which modify the internal state of the instance.


virtual void CLDate::Dump(CDumpContext& dc) const;

Standard MFC override to allow debugging output of the contents of this CLDate. This simply calls the Format method with the default Format and sends the results to the CDumpContext.


CString& CLDate::Format(const CString& sFormat=CLDate:: GetDefaultFormat()) const;

Generates a formatted string that corresponds to this CLDate object.

The function supports the following formats:

%a    Abbreviated weekday name

%A    Full weekday name

%b    Abbreviated month name

%B    Full month name

%d    Day of month as decimal number (01 - 31)

%j    Day of year as decimal number (001 - 366)

%m    Month as decimal number (01 - 12)

%P    AM / PM indicator

%U    Week of year as decimal number

%w    Weekday as decimal number (1 - 7; Sunday is 1)

%x    Date representation for current locale,  namely

        Date representation + " " + Time Representation for current locale

%y    Year without century, as decimal number (00 - 99)

%Y    Year with century, as decimal number

%c    Year displayed using C.E.(Current Epoch) / B.C.E (Before Current Epoch) convention e.g. -1023 = 1022 BCE

%t    String containing a representation of the TimeFrame ("UTC", "LOCAL" or "ET")

%H    Hours in the day

%h    12 Hour format Hours in (00 - 12)

%M    Minutes in the hour

%S    Seconds in the minute

%F    MilliSeconds in the second

%%    Percent sign

%#x Long date representation, appropriate to current locale, namely

      Long Date representation + " " + Time Representation for current locale

%#d, %#j, %#m, %#U, %#w, %#y, %#H, %#h, %#M, %#S  Remove leading zeros (if any).

Note:

1) The returned reference is to an internal static which will become overwritten upon subsequent calls which returns a CString reference.

2) If the CLDate is invalid then an empty string reference will be returned.


void CLDate::Serialize(CArchive& ar)
void CLDate::Serialize(CArchive& ar);

Standard MFC override to allow streaming of this CLDate to archive. The space taken is

exactly 12 bytes (10 data bytes + 2 schema bytes).


ostream& CLDate::operator<<(ostream &os, const CLDate& LDate);

Generates a formatted string to io stream that corresponds to this CDate object using the default format as specified by CLDate::SetDefaultFormat


friend CArchive& operator<<(CArchive& ar, CLDate& LDate);

Simply calls the Serialize method of “LDate”, asserting that the archive “ar” is storing.


friend CArchive& operator>>(CArchive& ar, CLDate& LDate);

Simply calls the Serialize method of “LDate”, asserting that the archive “ar” is loading.


Structures / Enums / Consts used by the Classes

enum CalendarType { JULIAN, GREGORIAN };

struct DateS

{

  LONG lYear;

  WORD wMonth;

  WORD wDay;

  WORD wWday;

  WORD wYday;

  CalendarType ct;

};

Note:

The year is interpreted as in CDate::GetYear

The month is interpreted as in CDate::GetMonth

The day is interpreted as in CDate::GetDay

The weekday (wWday) is interpreted as in CDate::GetDayOfWeek

The yearday (wYday) is interpreted as in CDate::DaysSinceJan0

enum TimeFrame {UTC, ET, LOCAL};

struct DateLS

{

  LONG lYear;

  WORD wMonth;

  WORD wDay;

  WORD nWday;

  WORD wYday;

  WORD wHour;

  WORD wMinute;

  WORD wSecond;

  WORD wMilliSeconds;

  CalendarType ct;

  TimeFrame tf;

};

Note:

The year is interpreted as in CDate::GetYear

The month is interpreted as in CDate::GetMonth

The day is interpreted as in CDate::GetDay

The weekday (wWday) is interpreted as in CDate::GetDayOfWeek

The yearday (wYday) is interpreted as in CDate::DaysSinceJan0

The hour is interpreted as in CLTimeOfDay::GetHour

The minute is interpreted as in CLTimeOfDay::GetMinute

The second is interpreted as in CLTimeOfDay::GetSecond

The millisecond is interpreted as in CLTimeOfDay::GetMilliSecond

enum MONTH { JANUARY=1,

               FEBRUARY=2,

               MARCH=3,

               APRIL=4,

               MAY=5,

               JUNE=6,

               JULY=7,

               AUGUST=8,

               SEPTEMBER=9,

               OCTOBER=10,

               NOVEMBER=11,

               DECEMBER=12};

enum DayOfWeek { SUNDAY=1,

                   MONDAY=2,

                   TUESDAY=3,

                   WEDNESDAY=4,

                   THURSDAY=5,

                   FRIDAY=6,

                   SATURDAY=7};

enum DateEpoch { EPOCH_JD,

                   EPOCH_MJD,

                   EPOCH_1900,

                   EPOCH_1950,

                   EPOCH_CTIME,

                   EPOCH_2000,

                   EPOCH_GREG};

const DWORD DT_ONLYVALID = 0x0001;

const DWORD DT_NOMILLISECOND = 0x0002;

const DWORD DT_NODRAG = 0x0004;

const DWORD DT_CLOSEONDEACTIVE = 0x0008;

const DWORD DT_PUSHPIN = 0x0010;

const DWORD DT_MODAL = 0x0020;

const DWORD DT_MODELESS = 0x0040;

const DWORD PLATFORM_WIN32S = 0;

const DWORD PLATFORM_WINDOWS95 = 1;

const DWORD PLATFORM_NT_WORKSTATION = 2;

const DWORD PLATFORM_WINDOWS = 3;

const DWORD PLATFORM_WINDOWSFW = 4;

const DWORD PLATFORM_DOS = 5;

const DWORD PLATFORM_NT_SERVER = 6;

const DWORD PLATFORM_NT_ADVANCEDSERVER = 7;

struct OS_VERSION_INFO

{

  DWORD dwOSVersionInfoSize;

  //What version of OS is being emulated

  DWORD dwEmulatedMajorVersion;

  DWORD dwEmulatedMinorVersion;

  DWORD dwEmulatedBuildNumber;

  DWORD dwEmulatedPlatformId;

  TCHAR szEmulatedCSDVersion[128];

  //What version of OS is really running

  DWORD dwUnderlyingMajorVersion;

  DWORD dwUnderlyingMinorVersion;

  DWORD dwUnderlyingBuildNumber;

  DWORD dwUnderlyingPlatformId;

  TCHAR szUnderlyingCSDVersion[128];

};


Julian Calendar

The Julian Calendar was the calendar system commonly in use throughout the Western world prior to the middle ages. It was established in the Roman Empire by Julius Caesar in the year -45 and reached its final form about the year +8. The main features of the Julian calendar were that a year consisted of 365 days except every 4 fours where an extra day is added, namely the 29 of February. This gives an average of 365.25 days which is quite close to the current value for the length of a solar year. The settings applet supplied with this package can be used to set when this calendar system ceased to be used in your country.


Gregorian Calendar

The Gregorian Calendar was a reform of the Julian Calendar to more accurately reflect the true length of a year with respect to our civil time-keeping. By the time of the 1600’s the seasons were out of sync with the calendar by almost 2 weeks. As a result the day following 1582 October 4 (Julian Calendar) is 1582 October 15 (Gregorian Calendar). In this system every fourth year is still leap with the following exception. If the year ends with two zeros, then the year is leap if it is divisible by 400 not 4. This means that an extra 3 days are lost every 400 years. This gives an average of 365.2425 days which is very close to the current value of a solar year. This new calendar system was not at once officially adopted by all countries. e.g. In Great Britain the change was made as late as 1752, and in Turkey not before 1927. The settings applet supplied with this package can be used to set when this calendar system was accepted in your country.


UCT TimeFrame

The UCT (Universal Co-ordinated Time) timeframe is used as the basis for civil time keeping on the earth. It was once referred to as GMT (Greenwich Mean Time). This time frame is not perfectly uniform and hence local time is not uniform also.  This is due to the irregularities of  the motion of the earth which it must track. When the arrival of atomic clocks and the need to perform accurate date calculations, another time frame namely Ephemeris Time was devised.


Local Timeframe

The Local Timeframe is defined as a fixed offset from UCT timeframe depending on where you are situated on the globe. This value is taken from the values stored by the Windows control panel applet “Date/Time”.


Ephemeris Timeframe

This timeframe is a uniform timeframe which is not constrained to staying in synch with the irregular motions of the earth. But astronomy and many other activities need a uniform time for accurate calculations. The difference occurs with unpredictable irregularities and can only be deduced from observation. This uniformity is required mainly when doing accurate astronomical calculations for the future and in historical times.


Julian Day

The Julian day number, or more simply the Julian Day (JD) is a continuous count of days and fractions thereof from the beginning of the year -4712 (4713 BCE).


Registration

Users of DTime must accept this disclaimer of warranty. If you do not accept this disclaimer, do not use DTime.

"DTIME IS SUPPLIED AS IS. THE AUTHOR DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE WARRANTIES OF MERCHANTABILITY AND OF FITNESS FOR ANY PURPOSE. THE AUTHOR ASSUMES NO LIABILITY FOR DAMAGES, DIRECT OR CONSEQUENTIAL, WHICH MAY RESULT FROM THE USE OF DTIME, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES."

"THE LICENCE AGREEMENT AND WARRANTY SHALL BE CONSTRUED, INTERPRETED AND GOVERNED BY THE LAWS OF IRELAND. YOU MAY HAVE OTHER RIGHTS WHICH VARY FROM ONE COUNTRY TO ANOTHER."

If you find DTime useful and you are continuing to use it after a trial period of 30 days, you must make a registration payment of £30 (Irish Punt’s or Sterling Pounds) or US$40 to the author. The payment can be made in Cheque, International Money Order or Cash (If you are willing to send it via post). Cheques or IMO’s should be made out to that author as in Contacting the Author.


Future Enhancements

Possible future additions include:

•	Port to MAC, PPC & other compilers.

•	Enhance data entry to allow extra ways of days to be entered e.g. the fourth Wednesday of a month, the 45 day of the year etc.

•	Add browse sequences to the help file.

•	Translate DTimeto more languages.

•	Include extra static constructors for other Holidays / Religions

•	Convert Dtset applet to a real control panel applet.

•	Include functions to wrap modification of values such as Daylight and Standard Time names and values.

•	Any other suggestions welcome.


Data Entry

Four classes are provided which subclass an edit control to produce a compound control to allow the four date / time classes to be connected to the user interface. The classes which do the actual Window sub - classing should not used directly (and are not documented here), instead a set of standard MFC DDX and DDV routines which wraps the sub - classing are documented and should be used.

Usage of the Data entry Routines

1) Place an edit control with the read only (ES_READONLY) style control on your dialog / form where you want the control to be using your resource editor.

2) Call the relevant DDX routine in your DoDataExchange member function for the control you wish to create with the edit controls dialog ID.

3) You may wish to use some flag variables to control how the drop down dialog is displayed in the call to DDX in 2) above.

4) Call the DDX routine for the value you want to allow to be edited via the control in 2) above.

5) Optionally call some of the DDV routines.

6) You will also need to add the following code to your CDialog class:

In your header:

#ifndef _WIN32

  afx_msg void OnEditButton();

#endif

In Your cpp file:

#ifndef _WIN32

  ON_COMMAND(DTIME_EDIT_CONTROL_ID, OnEditButton)

#endif

#ifndef _WIN32

void CDatentryDlg::OnEditButton()

{

  //reflect the message back down to the window which sent it to us

  const MSG* pMsg = GetCurrentMessage( );

  HWND hButton = (HWND) LOWORD(pMsg->lParam);

  ::SendMessage(hButton, UWM_BN_CLICKED, 0, 0L);

}

#endif

The reason for this code is that 16 bit MFC does not support message reflection. If your code is only going to be used with only MFC 4.X, then you don’t need this code.

The initial position of the edit control is used to position an extra button beside it which brings up the relevant dialog to allow data to be entered.

For a concrete example of using these controls, see the data entry program in the Demo Programs included with this package and the help for the DDX and DDV routines below.

CDate Data Entry

DDX_CDateControl

DDX_CDate

DDV_MinMaxCDate

DDV_GreaterThanCDate

DDV_LessThanCDate

When the CDate data entry control is properly setup it looks as follows:

And when the button is clicked the CDate dialog appears as follows:

When the “OK” button is hit, the edit control’s text is set, using the Format using the default parameter as follows:

CLTimeOfDay Data Entry

DDX_CLTimeOfDayControl

DDX_CLTimeOfDay

DDV_MinMaxCLTimeOfDay

DDV_GreaterThanCLTimeOfDay

DDV_LessThanCLTimeOfDay

When the CLTimeOfDay data entry control is properly setup it looks as the CDate control and when the button is clicked the CDate dialog appears as follows:

When the “OK” button is hit, the edit control’s text is set, using the Format using the default parameter as follows:

CLTimeSpan Data Entry

DDX_CLTimeSpanControl

DDX_CLTimeSpan

DDV_MinMaxCLTimeSpan

DDV_GreaterThanCLTimeSpan

DDV_LessThanCLTimeSpan

When the CLTimeSpan data entry control is properly setup it looks as the CDate control and when the button is clicked the CDate dialog appears as follows:

When the “OK” button is hit, the edit control’s text is set, using the Format using the default parameter as follows:

CLDate Data Entry

DDX_CLDateControl

DDX_CLDate

DDV_MinMaxCLDate

DDV_GreaterThanCLDate

DDV_LessThanCLDate

When the CLDate data entry control is properly setup it looks as the CDate control and when the button is clicked the CDate dialog appears as follows:

When the “OK” button is hit, the edit control’s text is set, using the Format using the default parameter as follows:

Note:

1) All the relevant controls are disabled when the invalid check box is selected and the edit controls text is emptied after the “OK” button is clicked.

2) Even though the dialogs do not have captions (to keep screen usage to a minimum) you can drag the dialogs (if you did not specify the DT_NODRAG flag).

3) Again to see the controls in action, See the data entry example in the Demo Programs included with this package.

Note:

4) The edit button that is created beside each text control will display a tooltip with the text “Modify” if the mouse hovers over it (if under 32 bit Windows).

5) The data entry routines is only available on Windows, not Dos.


void DDX_CDateControl(CDataExchange* pDX, int nIDC, CDateControl& rCDateControl, DWORD dwFlags);

Subclasses a standard edit control to allow it to enter a CDate. An “edit” button is created beside the edit control which displays the data entry dialog when clicked. This function would normally be called in your classes DoDataExchange function.

Parameters

pDX	Standard MFC data exchange class.

nIDC	Dialog ID of the edit control to subclass.

rCDateControl	CDateControl instance to associate with the newly sub-classed control.

dwFlags 	Flags to modify the behaviour of sub-classed control.

dwFlags can contain a bitwise combination of the following flags:

DT_ONLYVALID:	Only allows valid data to be entered.

DT_NODRAG:	Disallows dragging of the data entry dialog.

DT_CLOSEONDEACTIVE  Closes the drop down dialog when it loses focus, needs DT_MODELESS

DT_PUSHPIN	Displays a push pin in the drop down dialog, needs DT_MODELESS

DT_MODAL	Creates the drop down dialog as modal

DT_MODELESS	Creates the drop down dialog as modeless

Note:

1) The edit control must have the ES_READYONLY style as data entry is only allowed via the dialog which is displayed when the “edit” button is clicked.

2) See the data entry program in the Demo Programs included with this package for a concrete example.

3) At least the DT_MODAL or DT_MODELESS flag should be used.

4) See the CPushPinButton class for how DT_PUSHPIN is implemented.


void DDX_CLTimeSpanControl(CDataExchange* pDX, int nIDC, CLTimeSpanControl& rCLTimeSpanControl, DWORD dwFlags);

Subclasses a standard edit control to allow it to enter a CLTimeSpan. An “edit” button is created beside the edit control which displays the data entry dialog when clicked. This function would normally be called in your classes DoDataExchange function.

Parameters

pDX	Standard MFC data exchange class.

nIDC	Dialog ID of the edit control to subclass.

rCLTimeSpanControl	CLTimeSpanControl instance to associate with the newly sub-classed control.

dwFlags 	Flags to modify the behaviour of sub-classed control.

dwFlags can contain a bitwise combination of the following flags:

DT_ONLYVALID:	Only allows valid data to be entered

DT_NOMILLISECOND:	Do not show the millisecond field

DT_NODRAG:	Disallows dragging of the data entry dialog.

DT_CLOSEONDEACTIVE  Closes the drop down dialog when it loses focus, needs DT_MODELESS

DT_PUSHPIN	Displays a push pin in the drop down dialog, needs DT_MODELESS

DT_MODAL	Creates the drop down dialog as modal

DT_MODELESS	Creates the drop down dialog as modeless

Note:

1) The edit control must have the ES_READYONLY style as data entry is only allowed via the dialog which is displayed when the “edit” button is clicked.

2) See the data entry program in the Demo Programs included with this package for a concrete example.

3) At least the DT_MODAL or DT_MODELESS flag should be used.

4) See the CPushPinButton class for how DT_PUSHPIN is implemented.


void DDX_CLTimeOfDayControl(CDataExchange* pDX, int nIDC, CLTimeOfDayControl& rCLTimeOfDayControl, DWORD dwFlags);

Subclasses a standard edit control to allow it to enter a CLTimeOfDay. An “edit” button is created beside the edit control which displays the data entry dialog when clicked. This function would normally be called in your classes DoDataExchange function.

Parameters

pDX	Standard MFC data exchange class.

nIDC	Dialog ID of the edit control to subclass.

rCLTimeOfDayControl	CLTimeOfDayControl instance to associate with the newly sub-classed control.

dwFlags 	Flags to modify the behaviour of sub-classed control.

dwFlags can contain a bitwise combination of the following flags:

DT_ONLYVALID:	Only allows valid data to be entered

DT_NOMILLISECOND:	Do not show the millisecond field

DT_NODRAG:	Disallows dragging of the data entry dialog.

DT_CLOSEONDEACTIVE  Closes the drop down dialog when it loses focus, needs DT_MODELESS

DT_PUSHPIN	Displays a push pin in the drop down dialog, needs DT_MODELESS

DT_MODAL	Creates the drop down dialog as modal

DT_MODELESS	Creates the drop down dialog as modeless

Note:

1) The edit control must have the ES_READYONLY style as data entry is only allowed via the dialog which is displayed when the “edit” button is clicked.

2) See the data entry program in the Demo Programs included with this package for a concrete example.

3) At least the DT_MODAL or DT_MODELESS flag should be used.

4) See the CPushPinButton class for how DT_PUSHPIN is implemented.


void DDX_CLDateControl(CDataExchange* pDX, int nIDC, CLDateControl& rCLDateControl, DWORD dwFlags);

Subclasses a standard edit control to allow it to enter a CLDate. An “edit” button is created beside the edit control which displays the data entry dialog when clicked. This function would normally be called in your classes DoDataExchange function.

Parameters

pDX	Standard MFC data exchange class.

nIDC	Dialog ID of the edit control to subclass.

rCLDateControl	CLDateControl instance to associate with the newly sub-classed control.

dwFlags	 	Flags to modify the behaviour of sub-classed control.

dwFlags can contain a bitwise combination of the following flags:

DT_ONLYVALID:	Only allows valid data to be entered

DT_NOMILLISECOND:	Do not show the millisecond field

DT_NODRAG:	Disallows dragging of the data entry dialog.

DT_CLOSEONDEACTIVE  Closes the drop down dialog when it loses focus, needs DT_MODELESS

DT_PUSHPIN	Displays a push pin in the drop down dialog, needs DT_MODELESS

DT_MODAL	Creates the drop down dialog as modal

DT_MODELESS	Creates the drop down dialog as modeless

Note:

1) The edit control must have the ES_READYONLY style as data entry is only allowed via the dialog which is displayed when the “edit” button is clicked.

2) See the data entry program in the Demo Programs included with this package for a concrete example.

3) At least the DT_MODAL or DT_MODELESS flag should be used.

4) See the CPushPinButton class for how DT_PUSHPIN is implemented.


void DDX_CDate(CDataExchange* pDX, CDateControl& rCDateControl, CDate& value);

Transfers a CDate to and from the screen. This function would normally be called in your classes DoDataExchange function following a call to DDX_CDateControl

Parameters

pDX	Standard MFC data exchange class.

rCDateControl	CDateControl instance to retrieve/set the CDate value from/to.

value 	Value to retrieve/set.

Note:

1) See the data entry program in the Demo Programs included with this package for a concrete example.


void DDX_CLTimeOfDay(CDataExchange* pDX, CLTimeOfDayControl& rCLTimeOfDayControl, CLTimeOfDay& value);

Transfers a CLTimeOfDay to and from the screen. This function would normally be called in your classes DoDataExchange function following a call to DDX_CLTimeOfDayControl

Parameters

pDX	Standard MFC data exchange class.

rCDateControl	CLTimeOfDayControl instance to retrieve/set the CLTimeOfDay value from/to.

value 	Value to retrieve/set.

Note:

1) See the data entry program in the Demo Programs included with this package for a concrete example.


void DDX_CLTimeSpan(CDataExchange* pDX, CLTimeSpanControl& rCLTimeSpanControl, CLTimeSpan& value);

Transfers a CLTimeSpan to and from the screen. This function would normally be called in your classes DoDataExchange function following a call to DDX_CLTimeSpanControl

Parameters

pDX	Standard MFC data exchange class.

rCDateControl	CLTimeSpanControl instance to retrieve/set the CLTimeSpan value from/to.

value 	Value to retrieve/set.

Note:

1) See the data entry program in the Demo Programs included with this package for a concrete example.


void DDX_CLDate(CDataExchange* pDX, CLDateControl& rCLDateControl, CLDate& value);

Transfers a CLDate to and from the screen. This function would normally be called in your classes DoDataExchange function following a call to DDX_CLDateControl

Parameters

pDX	Standard MFC data exchange class.

rCDateControl	CLDateControl instance to retrieve/set the CLDate value from/to.

value 	Value to retrieve/set.

Note:

1) See the data entry program in the Demo Programs included with this package for a concrete example.


void DDV_MinMaxCDate(CDataExchange* pDX, CDate& value, CDate& minVal, CDate& maxVal);

Standard MFC validation routine. This function only allows a CDate to be entered between a certain range. This would normally be called in your classes DoDataExchange function following a call to DDX_CDate

Parameters

pDX	Standard MFC data exchange class.

Value	Value to check/validate.

minVal 	CDate than value must be greater than or equal to.

maxVal 	CDate than value must be less than or equal to.


void DDV_MinMaxCLTimeOfDay(CDataExchange* pDX, CLTimeOfDay& value, CLTimeOfDay& minVal, CLTimeOfDay& maxVal);

Standard MFC validation routine. This function only allows a CLTimeOfDay to be entered between a certain range. This would normally be called in your classes DoDataExchange function following a call to DDX_CLTimeOfDay

Parameters

pDX	Standard MFC data exchange class.

Value	Value to check/validate.

minVal 	CLTimeOfDay than value must be greater than or equal to.

maxVal 	CLTimeOfDay than value must be less than or equal to.


void DDV_MinMaxCLTimeSpan(CDataExchange* pDX, CLTimeSpan& value, CLTimeSpan& minVal, CLTimeSpan& maxVal);

Standard MFC validation routine. This function only allows a CLTimeSpan to be entered between a certain range. This would normally be called in your classes DoDataExchange function following a call to DDX_CLTimeSpan

Parameters

pDX	Standard MFC data exchange class.

Value	Value to check/validate.

minVal 	CLTimeSpan than value must be greater than or equal to.

maxVal 	CLTimeSpan than value must be less than or equal to.


void DDV_MinMaxCLDate(CDataExchange* pDX, CLDate& value, CLDate& minVal, CDate& maxVal);
void DDV_MinMaxCLDate(CDataExchange* pDX, CDate& value, CLDate& minVal, CLDate& maxVal);

Standard MFC validation routine. This function only allows a CLDate to be entered between a certain range. This would normally be called in your classes DoDataExchange function following a call to DDX_CLDate

Parameters

pDX	Standard MFC data exchange class.

Value	Value to check/validate.

minVal 	CLDate than value must be greater than or equal to.

maxVal 	CLDate than value must be less than or equal to.


void DDV_GreaterThanCDate(CDataExchange* pDX, CDate& value, CDate& minVal);

Standard MFC validation routine. This function only allows a CDate to be entered above a certain value. This would normally be called in your classes DoDataExchange function following a call to DDX_CDate

Parameters

pDX	Standard MFC data exchange class.

Value	Value to check/validate.

minVal 	CDate than value must be greater than or equal to.


void DDV_GreaterThanCLTimeOfDay(CDataExchange* pDX, CLTimeOfDay& value, CLTimeOfDay& minVal);

Standard MFC validation routine. This function only allows a CLTimeOfDay to be entered above a certain value. This would normally be called in your classes DoDataExchange function following a call to DDX_CLTimeOfDay

Parameters

pDX	Standard MFC data exchange class.

Value	Value to check/validate.

minVal 	CLTimeOfDay than value must be greater than or equal to.


void DDV_GreaterThanCLTimeSpan(CDataExchange* pDX, CLTimeSpan& value, CLTimeSpan& minVal);

Standard MFC validation routine. This function only allows a CLTimeSpan to be entered above a certain value. This would normally be called in your classes DoDataExchange function following a call to DDX_CLTimeSpan

Parameters

pDX	Standard MFC data exchange class.

Value	Value to check/validate.

minVal 	CLTimeSpan than value must be greater than or equal to.


void DDV_GreaterThanCLDate(CDataExchange* pDX, CLDate& value, CLDate& minVal);

Standard MFC validation routine. This function only allows a CLDate to be entered above a certain value. This would normally be called in your classes DoDataExchange function following a call to DDX_CLDate

Parameters

pDX	Standard MFC data exchange class.

Value	Value to check/validate.

minVal 	CLDate than value must be greater than or equal to.


void DDV_LessThanCDate(CDataExchange* pDX, CDate& value, CDate& maxVal);

Standard MFC validation routine. This function only allows a CDate to be entered below a certain value. This would normally be called in your classes DoDataExchange function following a call to DDX_CDate

Parameters

pDX	Standard MFC data exchange class.

Value	Value to check/validate.

maxVal 	CDate than value must be less than or equal to.


void DDV_LessThanCLTimeOfDay(CDataExchange* pDX, CLTimeOfDay& value, CLTimeOfDay& maxVal);

Standard MFC validation routine. This function only allows a CLTimeOfDay to be entered below a certain value. This would normally be called in your classes DoDataExchange function following a call to DDX_CLTimeOfDay

Parameters

pDX	Standard MFC data exchange class.

Value	Value to check/validate.

maxVal 	CLTimeOfDay than value must be less than or equal to.


void DDV_LessThanCLTimeSpan(CDataExchange* pDX, CLTimeSpan& value, CLTimeSpan& maxVal);

Standard MFC validation routine. This function only allows a CLTimeSpan to be entered below a certain value. This would normally be called in your classes DoDataExchange function following a call to DDX_CLTimeSpan

Parameters

pDX	Standard MFC data exchange class.

Value	Value to check/validate.

maxVal	CLTimeSpan than value must be less than or equal to.


void DDV_LessThanCLDate(CDataExchange* pDX, CLDate& value, CLDate& maxVal);

Standard MFC validation routine. This function only allows a CLDate to be entered below a certain value. This would normally be called in your classes DoDataExchange function following a call to DDX_CLDate

Parameters

pDX	Standard MFC data exchange class.

Value	Value to check/validate.

maxVal 	CLDate than value must be less than or equal to.


WORD ::GetDTimeVersion();

Returns the current version of the DTime package as a BYTE. It currently returns 1.11 encoded as follows:

HIBYTE = Major Version = 0x01

LOBYTE = Minor Version = 0x0b


BOOL ::InitDTimeSettings();

Transfers the settings as setup via the Settings Applet or environment variables to the protected static members of the DTime classes.

Returns TRUE if successful otherwise FALSE.

The values set are:

•	The date when the Julian calendar ceased in your country.

•	The date when the Gregorian calendar was introduced in your country.

•	The preferred CDate format which is used in calls to CDate::Format.

•	The preferred CLTimeSpan format which is used in calls to CDate::Format.

•	The preferred CLTimeOfDay format which is used in calls to CDate::Format.

•	The preferred CLDate format which is used in calls to CDate::Format.

•	The day of week the DTime classes will consider to be the beginning day of week.

Note:

1) Calling this function is optional, it depends on your own usage of the DTime package.

2) When under 16 bit Windows or Dos, environment variables are used instead of the registry as follows:

“DATE_FMT” is used to specify the default CDate format as a simple string.

“LDATE_FMT" is used to specify the default CLDate format as a simple string.

"TS_FMT" is used to specify the default CLTimeSpan format as a simple string.

"TOD_FMT" is used to specify the default CLTimeOfDay format as a simple string.

"BDOW" is used to specify the day of week DTime considers the first day of week as a value in CDate::SetBeginingDayOfWeek.

"JUL_END" is used to specify the date when the Julian calendar ended. It uses a “Day Month Year” format.

"GREG_BEGIN" is used to specify the date when the Gregorian calendar began. It uses a “Day Month Year” format.

As DTime uses a “%” to represent the escape character aswell as being used to represent environment variables you will need to use two “%”’s e.g. “%%d/%%m/%%c”


DTime Settings Applet

The applet supplied with this package allows a number of values relating to the DTime classes to be modified in a controlled way. The values are stored per user and can be inspected in the system registry under the HKEY_CURRENT_USER\Control Panel\DTime key using the regedit program supplied with Windows 95 & NT.

The Application allows the following parameters to be set:

•	The date when the Julian calendar ceased in your country.

•	The date when the Gregorian calendar was introduced in your country.

•	The preferred CDate format which is used in calls to CDate::Format.

•	The preferred CLTimeSpan format which is used in calls to CDate::Format.

•	The preferred CLTimeOfDay format which is used in calls to CDate::Format.

•	The preferred CLDate format which is used in calls to CDate::Format.

•	The day of week the DTime classes will consider to be the beginning day of week.

These values are taken from the registry and are initialised when the InitDTimeSettings() function is called.

Note:

1) The settings applet is a 32 bit Window program only as environment variables are used to modify DTime’s behaviour on Win16 and Dos.


Demo programs

A number of programs/projects are included with the DTime package namely:

1) DTime A VC4 project which builds the DTime package as an MFC extension dll.

Dt10016 is the Win16 release version of it.

dt10016d is the Win16 debug version of it.

2) Datentry A VC4 project which builds a GUI application to test the data entry routines.

Datent16 is the Win16 version of it.

3) DateTest A VC4 project which builds a Console application which test almost all of the DTime class API.

Datest16 is the Win16 version of it.

Dtestdos is the Dos version of it.

4) Dtset A VC4 project which builds the settings applet for the DTime classes.

See also: 	File Shipping List


File Shipping List

The following is a complete listing of all the files you should have received with this package.

datentry

datentry.h	main date entry application interface

datentry.cpp	main date entry application implementation

datentry.mak	date entry make file

datent16.mak	Win16 date entry make file

datentry.mdp	VC 4 date entry project make file

datentry.rc	date entry resources

datent16.rc	Win16 date entry resources

datent16.def	Win16 def file

datedlg.cpp	date entry dialog implementation (Including demonstrating

DDX routines and usage of customisation flags)

datedlg.h	date entry dialog interface

resource.h	Standard VC list of resource symbols

stdafx.cpp	Standard VC PCH implementation

stdafx.h	Standard VC PCH interface

res

datentry.ico	icon for date entry application

datentry.rc2	manually edited resources

3dcheck.bmp	3d bitmap for ctl3d

datetest

datetest.cpp	main date test application

datetest.mak	date test make file

datest16.mak	Win16 date test make file

dtestdos.mak	Dos test make file

datetest.mdp	VC 4 date test project make file

stdafx.cpp	Standard VC PCH implementation

stdafx.h	Standard VC PCH interface

dtset

dtset.cpp	main dtset applet interface

dtset.h	main dtset applet implementation

dtset.mak	dtset make file

dtset.mdp	VC 4 dtset project make file

dtset.rc	dtset resources

dtsetdlg.cpp	dtset dialog implementation

dtsetdlg.h	dtset dialog interface

resource.h	Standard VC list of resource symbols

stdafx.cpp	Standard VC PCH implementation

stdafx.h	Standard VC PCH interface

res

dtset.ico	icon for dtset applet

dtset.rc2	manually edited resources

src

datetime.cpp	Underlying Date / time classes

dentry.cpp	Classes & functions to handle connection to UI

dtime.cpp	main extension dll implementation

dtime.mak	Win32 dtime make file

dt10016.mak	Win16 release dtime make file

dt10016d.mak	Win16 debug make file

dtwinver.cpp	OS version detection function

dtime.mdp	VC 4 dtime project make file

dtime.clw	Class Wizard info file

dtime.rc	dtime resources

dtime16.rc	Win16 dtime resources

pushpin.cpp	Push pin button class

resource.h	Standard VC list of resource symbols

stdafx.cpp	Standard VC PCH implementation

stdafx.h	Standard VC PCH interface

win32sup.cpp	Additional functions and classes to allow core DTime code to be portable between Win32, Win16 & Dos

dtime.rc2	manually edited resources

res

datentry.ico	DTime icon

nightsky.bmp	DTime bitmap

pushpind.bmp	push pin “Down” state bitmap

pushpinu.bmp	Push pin “Up” state bitmap

l.eng

dtime.rc2	English manually edited resources

dtime16.rc	English Win16 dtime resources

l.deu

dtime.rc2	German manually edited resources

dtime16.rc	German Win16 dtime resources

include

dtime.h	main DTime include (includes all other header files)

datetime.h	Underlying Date / time classes

datentry.h	Classes & functions to handle connection to UI

dtimeres.h	help ids for all message boxes DTime generates

pushpin.h	Push pin button class

dtwinver.h	OS version detection function

win32sup.h	Additional functions and classes to allow core DTime code to be portable between Win32, Win16 & Dos

lib

dt100.lib	Win32 Intel Ascii Release library for DTime

dt100d.lib	Win32 Intel Ascii Debug library for DTime

dt10016.lib	Win16 Intel Ascii Release library for DTime

dt10016d.lib	Win16 Intel Ascii Debug library for DTime

dt100du.lib	Win32 Intel Unicode Debug library for DTime

dt100u.lib	Win32 Intel Unicode Release library for DTime

bin

dt100.dll	Win32 Intel Ascii Release DTime dll

dt100d.dll	Win32 Intel Ascii Debug DTime dll

dt10016.dll	Win16 Intel Ascii Release DTime dll

dt10016d.dll	Win16 Intel Ascii Debug DTime dll

dt100du.dll	Win32 Intel Unicode Debug DTime dll

dt100u.dll	Win32 Intel Unicode Release DTime dll

dtime.hlp	help file for DTime extension dll

readme.txt	Short text file containing description of DTime package


BOOL GetOSVersion(LPOS_VERSION_INFO lpVersionInformation);

This routine provides a comprehensive method to determine which OS the program that calls it is running on. All methods it uses are fully documented on various articles on the MSDN CD. The routine provides the emulated OS aswell as the underlying OS. e.g to a Dos program Windows 95 looks like MS-DOS 7.0. A full list of the OS’s it can detect are:

Win32s

Windows 95

NT Workstation

NT Server

NT Advanced Server

Windows for Workgroups

Windows 3.0 - 3.11

Dos

Some of the possible scenarios it can report on are:

1) “You are running an emulated Dos v5.50 On NT”

2) “You are running an emulated Windows 3.95 on Windows 95 v4.0 Build 950”

3) “You are running Windows for Workgroups on Dos v6.22”

4) “You are running NT Advanced Server v3.51”

An example of its usage is a TRACE statement that the InitDTime function issues.

Other areas where this may prove useful are:

1) “A Dos program wants to know if it can be allowed access to hardware ports which is not available on NT, but is available on Dos, Windows 3.x & Windows 95”.

2) “A Win32 program wants to know if the Windows 95 UI is available”

3) “A Win16 program wants to know if it can call the Win32 API via generic thunking”

Note:

1) See the Structures used by the classes for the definition of the consts / structures used by this function.


DWORD GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation);

This function is implemented / available when DTime is compiled for Win16 or Dos. It is intended to be a direct replacement of the Win32 SDK function of the same name. The settings it retrieves are taken from the following environment variables:

“TZ”	The Daylight name, Standard name and daylight bias are taken from this standard variable as defined by the “C” runtime routines.

“STD_DATE” This specifies the date when Standard time is to take effect. The format is: “Year Month WeekOfDay Day Hour Minute Second”. The values are interpreted as in the Win32 SDK function.

“DYLT_DATE” This specifies the date when Daylight time is to take effect. The format is: “Year Month WeekOfDay Day Hour Minute Second”. The values are interpreted as in the Win32 SDK function.

Note:

1) See the Structures used by the classes for the definition of the consts / structures used by this function.


void TermDTime();

This function should be called after using DTime. You would usually call this in ExitInstance()

or at the end of main() or wmain() depending on which environment you are building your program for.


int Win16Printf(const char *format, ...);

This function is available when DTime is built for Win16. It syntax is the same as the runtime function “printf” and the results are directed to debug output via the SDK function OutputDebugString. The return value is the number of characters actually output.


void InitDTime();

This function should be called prior to using DTime. You would usually call this at the start of InitInstance(), main() or wmain() depending on which environment you are building your program for.


CStringEx Class

When DTime is compiled for Win16 or Dos, All references to the built-in MFC class CString get replaced by the CStringEx class as declared in “win32sup.h”. This class is used to provide a CString::Format function in Win16 and Dos. It also provides a CString::LoadString equivalent when compiled for Dos which loads from an internal table as opposed to a real resource table.

Use of this class on these environments thus allows the continued use of the CString class without the use of #ifdef statements in application code. This class is exported and can thus be used by code outside of DTime if so desired.


CPushPinButton Class

To implement the DT_PUSHPIN flag for the DTime Data Entry routines, a CPushPinButton class was used and is available for external use. Its appearance is similar to the pin button as seen on the OpenLook window manager on X-Windows & property dialogs in VC 4. It has the following appearance when used to enter a CLTimeSpan instance:

The class is derived from CBitmapButton and can be easily used as follows:

1) Create a dialog template with an owner-draw button positioned where you want the push pin button. The size of the button in the template does not matter.

2) Set the button’s caption to the value “PIN” and define a symbol for the button such as IDC_MYIMAGE.

3) In your application’s dialog class (derived from CDialog), add a CPushPinButton member object.

4) In the CDialog object’s OnInitDialog routine, call the CBitmapButton object’s AutoLoad function, using as parameters the button’s control ID and the CDialog object’s this pointer.

A single member function “IsPinned()” of CPushPinButton is available which returns TRUE if the pin is down otherwise FALSE is returned. To see the class being used see the datentry.cpp module in the src directory of DTime.

Note:

1) The push pin will display a tooltip with the text “Keep Visible” if the mouse hovers over it (when compiled for 32 bit Windows).


How to use DTime

After you have installed DTime, You will need to modify your lib and include directories to include the relevant DTime directories.To use the DTime extension dll in your MFC app, Simply include the correct lib file in your build and make sure the program can find the corresponding dll at runtime. You can then include the main header file ”DTIME.H” in any of your source files which want to access DTime classes / functions. You will also need to call InitDTime and TermDTime functions at the correct place in your code.

App Type	DTime lib to use	DTime dll to use

Win32 Ascii Debug	dt100d.lib	dt100d.dll

Win32 Ascii Release	dt100.lib	dt100.dll

Win32 Unicode Debug	dt100du.lib	dt100du.dll

Win32 Unicode Release	dt100u.lib	dt100u.dll

Win16 Ascii Debug	dt10016d.lib	dt10016d.dll

Win16 Ascii Release	dt10016.lib	dt10016.dll

Note:

To use DTime under Dos, Just include the following files in your project: datetime.cpp, dtwinver.cpp, dtime.cpp & win32sup.cpp and then include the main header file ”DTIME.H” in any of your source files which want to access DTime classes / functions.


Revision History

Included below is a list of the changes made for each version of DTime.

Version	Description of Changes / Bug Fixes

1.0	Initial public Win32 release.

1.1	1) Port to Win16 and Dos.

2) Implementation of a comprehensive OS detection routine.

3) A number of classes and functions to make code portable across OS platforms.

4) Addition of a number of member functions to return a c runtime tm struct version.

5) TermDTime added and InitDTimeDll now renamed to InitDTime.

6) “printf” like function made available under Win16.

7) A CStringEx class which provides a Format method under Win16 and Dos and a LoadString method under Dos.


Uninstalling DTime

The DTime setup program does not provide an automated way of removing itself, but it does not transfer anything to your hard disk outside of the directory where you installed it to. To remove it completely from your hard disk, it’s just requires you to delete the directory where you installed it to. During your use of DTime you may have copied some of its dlls into your Windows or Windows system directory, You can safely delete these also. The following six types of DTime dll can exist:

App Type	DTime dll to use

Win32 Ascii Debug	dt100d.dll

Win32 Ascii Release	dt100.dll

Win32 Unicode Debug	dt100du.dll

Win32 Unicode Release	dt100u.dll

Win16 Ascii Debug	dt10016d.dll

Win16 Ascii Release	dt10016.dll


German Version of DTime

Under Win16 and Win32, DTime can be used in the german language. Under Win32, you do not need to do anything extra to get this functionality, just run your program with Germany set as your locale in the control panel and all of DTime’s resources should then appear in the german language. You can achieve the same result programmatically by calling the Win32 SDK function SetThreadLocale(). See the datetest.cpp or datentry.cpp modules for an example of using this.

Under Win16, you need to copy the files which appear in the “src\l.deu” directory into the “src” directory. You can then rebuild the win16 version of DTime using the relevant Win16 mak file. The “src\i.eng” contains the original english resources so that you can get back to the english version of DTime when you want to.